The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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.

METHODS

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::*.

        my $Exception = PayProp::API::Public::Client::Exception::Custom->throw('I am an exception!');

        or

        my $Exception = 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;

AUTHOR

Yanga Kandeni <yangak@cpan.org>

Valters Skrupskis <malishew@cpan.org>

COPYRIGHT

Copyright 2023- PayProp

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

If you would like to contribute documentation or file a bug report then please raise an issue / pull request:

https://github.com/Humanstate/api-client-public-module