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?
requestHTTP::Request object containing request which caused failure.
responseHTTP::Response object containing obtained reply (error reply).
codeShortcut. HTTP error code (400, 401, 500, ...).
statusShortcut. HTTP status line
oauth_problemIf description of actual OAuth problem was detected, appropriate text code, for example parameter_absent, token_revoked, consumer_key_rejected, ...
See http://wiki.oauth.net/w/page/12238543/ProblemReporting for possible values.
detailError detail. Formatted from information available in response content (if format was not recognized, this very content by itself).
struct_detailDeserialized 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' },
}
methodShortcut. HTTP method (GET, POST, PUT, DELETE)
uriShortcut. 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
}
};
identShort error description
extraAdditional, more elaborate, information.