The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Dancer2::RPCPlugin::ErrorResponse - Interface to pass error-responses without knowlage of the protocol

SYNOPSIS

    use Dancer2::RPCPlugin::ErrorResponse;

    sub handle_rpc_call {
        ...
        return error_response(
            error_code => 42,
            error_message => 'That went belly-up',
        );
    }

DESCRIPTION

error_response(%parameters) [EXPORTED]

Factory function that retuns an instantiated Dancer2::RPCPlugin::ErrorResponse.

Parameters

error_code => $error_code [required]
error_message => $error_message [required]
error_data => $error_data [optional]

Responses

An instance or an exception from Moo.

register_error_responses(@parameters)

This method makes it posible to extend the RPC-plugin system with ones own error handlers.

Parameters

Positional:

1. $plugin [Required]

One the registered RPC-plugins.

2. $status_map [Required]

A hashref with a mapping between error-codes produced by this RPC-prototcol and the HTTP-return status codes. There is a special code value default that is used for unregistered error-codes.

3. $handler_name [Optional]

This is the name of the error handler one wants to add to this class.

4. $error_handler [Optional]

This is a CodeRef for the error handler one wants to add for the new RPC-protocol.

Dancer2::RPCPlugin::ErrorResponse->new(%parameters)

Parameters

error_code => $error_code [required]
error_message => $error_message [required]
error_data => $error_data [optional]

Responses

An instance or an exception from Moo.

$er->error_code

Getter for the error_code attribute.

$er->error_message

Getter for the error_message attribute.

$er->error_data

Getter for the error_data attribute.

$er->return_status

Returns the HTTP return status code for this error-code.

$er->as_jsonrpc_error

Returns a data-structure for the use in the error field of a jsonrpc response.

$er->as_xmlrpc_fault

Returns a data-structure for the use as a fault response in XMLRPC.

$er->as_restrpc_error

Returns a data-structure like the error-field in a JSONRPC2 error response.

COPYRIGHT

(c) MMXVII - Abe Timmerman <abetim@cpan.org>