NAME
Twilio::Exceptions::RestException - Twilio answered a request with an error
SYNOPSIS
use Scalar::Util qw(blessed);
my $ok = eval { $client->messages->create($to, { from => $from, body => $body }); 1 };
if (!$ok) {
my $error = $@;
die $error unless blessed($error) && $error->isa('Twilio::Exceptions::RestException');
warn sprintf("HTTP %d, Twilio error %d: %s\nSee %s\n",
$error->get_status_code, $error->get_code, $error->get_message, $error->get_more_info);
}
DESCRIPTION
Thrown when the Twilio API returns an error response. It adds the HTTP status and Twilio's error details to Twilio::Exceptions::TwilioException.
METHODS
new
my $error = Twilio::Exceptions::RestException->new(
$message, $code, $status_code, $more_info, $details);
Creates an exception without throwing it.
get_code
Inherited. Returns the Twilio error code, such as 21211, or the HTTP status when the response carried no code.
get_status_code
Returns the HTTP status code.
get_more_info
Returns the URL of the documentation page for this error, or an empty string.
get_details
Returns a hash reference of additional error details.
LICENSE
Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.