NAME
PayProp::API::Public::Client::Exception::Base - Base module for exceptions.
SYNOPSIS
{
package PayProp::API::Public::Client::Exception::Custom;
use parent qw/ PayProp::API::Public::Client::Exception::Base /;
# Optional error class to construct C<errors> field.
sub error_class { 'PayProp::API::Public::Client::Error::Custom' }
# Optional error fields as defined in C<PayProp::API::Public::Client::Error::Custom>
sub error_fields { qw/ custom_field_1 / }
1;
}
PayProp::API::Public::Client::Exception::Custom->throw(
status_code => 500,
errors => [
{ custom_field_1 => 'Hello' },
],
);
DESCRIPTION
*DO NOT INSTANTIATE THIS MODULE DIRECTLY*
This is a base exception module from which specific exceptions are extended. For new exception types use this module as a parent.
See PayProp::API::Public::Client::Exception::*
for examples.
error_class
Can be optionally overridden in PayProp::API::Public::Client::Exception::*
.
error_fields
Can be optionally overridden in PayProp::API::Public::Client::Exception::*
.
throw
Main method to call to throw an exception from PayProp::API::Public::Client::Exception::*
.
PayProp::API::Public::Client::Exception::Custom->throw('I am an exception!');
or
PayProp::API::Public::Client::Exception::Custom->throw(
status_code => 500,
errors => [
{ custom_field_1 => 'Hello' },
],
);
errors
Return instances of PayProp::API::Public::Client::Error::*
, if defined.
my $errors = PayProp::API::Public::Client::Exception::Custom->errors;
status_code
Return exception status code, if defined.
my $status_code = PayProp::API::Public::Client::Exception::Custom->status_code;
Fields
To be extended for additional fields to be available on PayProp::API::Public::Client::Exception::*
.
to_hashref
Convert PayProp::API::Public::Client::Exception::*
to hashref, in place for easier debugging.
my $error_ref = PayProp::API::Public::Client::Exception::Custom->to_hashref;
Return:
{
class => 'PayProp::API::Public::Client::Exception::Custom',
message => 'Given message',
status_code => 500,
errors => [
{
class => 'PayProp::API::Public::Client::Error::Custom',
fields => {
custom_field_1 => 'Hello',
},
},
],
}