NAME
Twitter::API::Error - Twitter API exception
VERSION
version 0.0103
SYNOPSIS
use Try::Tiny;
use Twitter::API;
use Twitter::API::Util 'is_twitter_api_error';
my $client = Twitter::API->new(%options);
try {
my $r = $client->get('account/verify_credentials');
}
catch {
die $_ unless _is_twitter_api_error;
warn "Twitter says: ", $_->twitter_error_text;
};
DESCRIPTION
Twitter::API dies, throwing a Twitter::API::Error exception when it receives an error. The error object contains information about the error so your code can decide how to respond to various error conditions.
METHODS
http_request
Returns the HTTP::Request object used to make the Twitter API call.
http_response
Returns the HTTP::Response object for the API call.
twitter_error
Returns the inflated JSON error response from Twitter (if any).
stack_trace
Returns a Devel::StackTrace object encapsulating the call stack so you can discover, where, in your application the error occurred.
stack_frame
Delegates to <stack_trace-
frame>>. See Devel::StackTrace for details.
next_stack_fram
Delegates to <stack_trace-
next_frame>>. See Devel::StackTrace for details.
error
Returns a reasonable string representation of the exception. If Twitter returned error information in the form of a JSON body, it is mined for error text. Otherwise, the HTTP response status line is used. The stack frame is mined for the point in your application where the request initiated and appended to the message.
When used in a string context, error
is called to stringify exception.
twitter_error_code
Returns the numeric error code returned by Twitter, or 0 if there is none. See https://dev.twitter.com/overview/api/response-codes for details.
is_token_error
Returns true if the error represents a problem with the access token or its Twitter account, rather than with the resource being accessed.
Some Twitter error codes indicate a problem with authentication or the token/secret used to make the API call. For example, the account has been suspended or access to the application revoked by the user. Other error codes indicate a problem with the resource requested. For example, the target account no longer exists.
http_response_code
Delegates to <http_response-
code>>. Returns the HTTP status code of the response.
is_pemanent_error
Returns true for HTTP status codes representing an error and with values less than 500. Typically, retrying an API call with one of these statuses right away will simply result in the same error, again.
is_temporary_error
Returns true or HTTP status codes of 500 or greater. Often, these errors indicate a transient condition. Retrying the API call right away may result in success. See the RetryOnError for automatically retrying temporary errors.
AUTHOR
Marc Mims <marc@questright.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015-2016 by Marc Mims.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.