NAME
Twilio::Exceptions::TwilioException - Base class of every exception in this library
SYNOPSIS
use Scalar::Util qw(blessed);
my $ok = eval { $client->request('GET', $url); 1 };
if (!$ok) {
my $error = $@;
die $error unless blessed($error) && $error->isa('Twilio::Exceptions::TwilioException');
warn 'Twilio failed: ' . $error->get_message;
}
DESCRIPTION
All errors raised by this library are objects of this class or of a subclass, thrown with die. An exception stringifies to its message, so code that prints $@ still shows something useful.
METHODS
new
my $error = Twilio::Exceptions::TwilioException->new($message, $code);
Creates an exception without throwing it.
throw
Twilio::Exceptions::TwilioException->throw($message, $code);
Creates an exception and dies with it.
get_message
Returns the error message.
get_code
Returns the error code, or 0 when there is none.
LICENSE
Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.