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

PONAPI::DAO::Exception - PONAPI - Perl implementation of {JSON:API} (http://jsonapi.org/) v1.0

VERSION

version 0.001000

SYNOPSIS

    use PONAPI::DAO::Exception;
    PONAPI::DAO::Exception->throw( message => "Generic exception" );
    PONAPI::DAO::Exception->throw(
        message => "Explanation for the sql error, maybe $DBI::errstr",
        sql     => 1,
    );
    PONAPI::DAO::Exception->throw(
        message          => "Data had type `foo` but we wanted `bar`",
        bad_request_data => 1,
    );

DESCRIPTION

PONAPI::DAO::Exception can be used by repositories to signal errors; exceptions thrown this way will be caught by the DAO and handled gracefully.

Different kinds of exceptions can be thrown by changing the arguments to throw; sql => 1 will throw a SQL exception, bad_request_data => 1 will throw an exception due to the input data being wrong, and not passing any of those will throw a generic exception.

The human-readable message for all of those will end up in the error response returned to the user.

NAME

PONAPI::DAO::Exception - Exceptions for PONAPI

METHODS

message

This attribute contains the exception message.

stack_trace

This contains the stack trace of the exception.

as_string

Returns a stringified form of the exception. The object is overloaded to return this if used in string context.

as_response

Returns the exception as a 3-element list that may be fed directly to plack as a {json:api} response.

    $e->as_response; # ( $status, [], { errors => [ { detail => $message } ] } )

json_api_version

Defaults to 1.0; only used in as_response.

status

HTTP Status code for the exception; in most cases you don't need to set this manually.

AUTHOR

Mickey Nasriachi <mickey AT cpan DOT org>, Stevan Little <stevan AT cpan DOT org>, Brian Fraser <hugmeir AT cpan DOT org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Mickey Nasriachi, Stevan Little, Brian Fraser.

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

1 POD Error

The following errors were encountered while parsing the POD:

Around line 201:

'=end' without a target?