File Coverage

blib/lib/Business/Monzo/Exception.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 1 1 100.0
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Business::Monzo::Exception;
2              
3             =head1 NAME
4              
5             Business::Monzo::Exception
6              
7             =head1 DESCRIPTION
8              
9             Exception handling for the Business::Monzo modules, uses the Throwable
10             module.
11              
12             =cut
13              
14 11     11   967 use strict;
  11         30  
  11         363  
15 11     11   78 use warnings;
  11         35  
  11         340  
16              
17 11     11   510 use Moo;
  11         12354  
  11         69  
18 11     11   5555 use Carp qw/ cluck /;
  11         35  
  11         2254  
19              
20             with 'Throwable';
21              
22             =head1 ATTRIBUTES
23              
24             =head2 message (required)
25              
26             The error message.
27              
28             =head2 code (optional)
29              
30             The error code, generally the HTTP status code.
31              
32             =head2 response (optional)
33              
34             The error response, generally the HTTP response.
35              
36             =head2 request (optional)
37              
38             The original HTTP request data including path, params, content, and headers.
39             You should be careful if you write this data to a file as it may contain
40             sensitive information such as API key(s).
41              
42             =cut
43              
44             # plain string or JSON
45             has message => (
46             is => 'ro',
47             required => 1,
48             coerce => sub {
49             my ( $message ) = @_;
50             cluck $message if $ENV{MONZO_DEBUG};
51             return $message;
52             },
53             );
54              
55             # HTTP status code, response, request
56             has [ qw/ code response / ] => (
57             is => 'ro',
58             required => 0,
59             );
60              
61             has [ qw/ request / ] => (
62             is => 'ro',
63             required => 0,
64             );
65              
66             =head1 METHODS
67              
68             =head2 description
69              
70             An alias to the message attribute.
71              
72             =cut
73              
74             # compatibility with ruby lib
75 1     1 1 1366 sub description { shift->message }
76              
77             =head1 AUTHOR
78              
79             Lee Johnson - C<leejo@cpan.org>
80              
81             This library is free software; you can redistribute it and/or modify it under
82             the same terms as Perl itself. If you would like to contribute documentation,
83             features, bug fixes, or anything else then please raise an issue / pull request:
84              
85             https://github.com/leejo/business-monzo
86              
87             =cut
88              
89             1;
90              
91             # vim: ts=4:sw=4:et