WebAuth::Exception(3pm) | User Contributed Perl Documentation | WebAuth::Exception(3pm) |
WebAuth::Exception - Rich exception for errors from WebAuth API methods
my $token; my $wa = WebAuth->new; eval { $token = $wa->token_decode ($input); # ... }; if ($@ && ref ($@) eq 'WebAuth::Exception') { my $e = $@; print 'status: ', $e->status, "\n"; print 'message: ', $e->error_message, "\n"; print 'detail: ', $e->detail_message, "\n"; print "$e\n"; die $e->verbose_message; }
All WebAuth methods, and most methods in WebAuth::Key, WebAuth::Keyring, WebAuth::KeyringEntry, and WebAuth::Token::* classes, will throw an exception on error. Exceptions produced by the underlying C API call will be represented by a WebAuth::Exception object.
You can use this object like you would normally use $@ and print it out or do string comparisons with it and it will convert to the string representation of the complete error message. But you can also access the structured data stored inside the exception by treating it as an object and using the methods defined below.
Roland Schemers and Russ Allbery <eagle@eyrie.org>.
This module is part of WebAuth. The current version is available from <http://webauth.stanford.edu/>.
2019-01-05 | perl v5.28.1 |