OAuthomatic::Error - structured exceptions thrown by OAuthomatic
Errors defined here allow for inspection of various error details.
try { OAuthomatic::Error::Sth->throw({ ident => 'short description', # ... other params }); } catch { my $error = $_; if ($error->isa('OAuthomatic::Error')) { print $error->message, "\n\n", $error->stack_trace->as_string; # Or use class-dependant fields } };
Object representing various communication and OAuth-protocol related failures.
try { OAuthomatic::Error::HTTPFailure->throw({ ident => 'OAuth HTTP request failed', request => $request, # HTTP::Request response => $response, # HTTP::Response }); } catch { my $error = $_; if ($error->isa('OAuthomatic::Error::HTTPFailure')) { print "$error\n"; # message print $error->stack_trace->as_string; # if necessary if($error->is_new_client_key_required) { # request new client (application) key } elsif($error->is_new_token_required) { # redo authorization sequence } # See also other fields - code, uri, struct_detail } };
is_new_client_key_required()
Do details of this error mean, that OAuth client key in use is no longer valid and should be replaced?
is_new_token_required()
Do details of this error mean, that OAuth token in use is no longer valid and application should get new one?
request
HTTP::Request object containing request which caused failure.
response
HTTP::Response object containing obtained reply (error reply).
code
Shortcut. HTTP error code (400, 401, 500, ...).
status
Shortcut. HTTP status line
oauth_problem
If description of actual OAuth problem was detected, appropriate text code, for example parameter_absent, token_revoked, consumer_key_rejected, ...
parameter_absent
token_revoked
consumer_key_rejected
See http://wiki.oauth.net/w/page/12238543/ProblemReporting for possible values.
detail
Error detail. Formatted from information available in response content (if format was not recognized, this very content by itself).
struct_detail
Deserialized error detail in case output contains form-encoded data. Handles:
Frequently used in OAuth initial protocol sequences, for example you may see here:
{ oauth_problem => 'parameter_absent', oauth_parameters_absent => 'oauth_consumer_key', }
For example
{ error => { id => '9e9c7bddeff3', message => 'Object already deleted' }, }
method
Shortcut. HTTP method (GET, POST, PUT, DELETE)
uri
Shortcut. URI object representing the call.
Object representing non-HTTP related exception (mostly various cases of bad parameters and programming errors).
try { OAuthomatic::Error::Generic->throw({ ident => 'Required parameter missing', extra => "Neither body, nor body_params provided." }); } catch { my $error = $_; if ($error->isa('OAuthomatic::Error::Generic')) { print "$error\n"; # message print $error->stack_trace->as_string; # if necessary } };
ident
Short error description
extra
Additional, more elaborate, information.
To install OAuthomatic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OAuthomatic
CPAN shell
perl -MCPAN -e shell install OAuthomatic
For more information on module installation, please visit the detailed CPAN module installation guide.