Monzo/Exception.pm

filter: Statementstmt 100% 21 / 21 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 96.6% 29 / 30 CC 2 SCAR 2.6
CC
2
Cov
96%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« Monzo/Merchant.pm ↑ Summary Monzo/Pot.pm »
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 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 12 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 12 ▶use Carp qw/ cluck /;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 12 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 12 ▶ coerce => sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
49 12 my ( $message ) = @_;
50 12 ▶ cluck $message if $ENV{MONZO_DEBUG};
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"MONZO_DEBUG"} 0 12 12
51 12 return $message;
52 },
53 12 );
54  
55 # HTTP status code, response, request
56 12 has [ qw/ code response / ] => (
57 is => 'ro',
58 required => 0,
59 );
60  
61 12 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 ▶sub description { shift->message }
Subroutine description: called CC=1 SCAR=0.0
Pod documented
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 12 1;
90  
91 # vim: ts=4:sw=4:et
« Monzo/Merchant.pm ↑ Summary Monzo/Pot.pm »