Net::Duo::Exception(3pm) | User Contributed Perl Documentation | Net::Duo::Exception(3pm) |
Net::Duo::Exception - Rich exception object for Net::Duo failures
use 5.010; # Use by a caller of the Net::Duo API. my $duo = Net::Duo->new({ key_file => '/path/to/keys.json' }); if (!eval { $duo->check() }) { my $e = $@; say 'Code: ', $e->code(); say 'Message: ', $e->message(); say 'Detail: ', $e->detail(); print "\nFull reply content:\n", $e->content(); } # Use internally by Net::Duo objects. die Net::Duo::Exception->propagate($@); die Net::Duo::Exception->internal('some error message'); my $response = some_http_call(); die Net::Duo::Exception->http($response); my $reply = some_duo_call(); die Net::Duo::Exception->protocol('error message', $reply); die Net::Duo::Exception->api($reply);
Perl 5.14 or later and the module HTTP::Message, which is available from CPAN.
Net::Duo::Exception is a rich representation of errors from any Net::Duo API. All Net::Duo APIs throw Net::Duo::Exception objects on any failure, including internal errors, protocol errors, HTTP errors, and failures returned by the Duo API. This object carries all available details about the failure and can be inspected by the caller to recover additional information. If the caller doesn't care about the details, it provides a stringification that is suitable for simple error messages.
All class methods are constructors. These are primarily for the internal use of Net::Duo classes to generate the exception and will normally not be called by users of Net::Duo. Each correspond to a type of error and tell Net::Duo::Exception what data to extract to flesh out the exception object.
These are the methods most commonly called by programs that use the Net::Duo module. They return various information from the exception.
Russ Allbery <rra@cpan.org>
Copyright 2014 The Board of Trustees of the Leland Stanford Junior University
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Net::Duo
This module is part of the Net::Duo distribution. The current version of Net::Duo is available from CPAN, or directly from its web site at <https://www.eyrie.org/~eagle/software/net-duo/>.
2022-12-18 | perl v5.36.0 |