File Coverage

lib/Net/API/CPAN/Exception.pm
Criterion Covered Total %
statement 10 10 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 14 100.0


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Meta CPAN API - ~/lib/Net/API/CPAN/Exception.pm
3             ## Version v0.1.0
4             ## Copyright(c) 2023 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2023/07/26
7             ## Modified 2023/07/26
8             ## All rights reserved
9             ##
10             ## This program is free software; you can redistribute it and/or modify it
11             ## under the same terms as Perl itself.
12             ##----------------------------------------------------------------------------
13             package Net::API::CPAN::Exception;
14             BEGIN
15             {
16 1     1   1023 use strict;
  1         2  
  1         37  
17 1     1   7 use warnings;
  1         2  
  1         44  
18 1     1   6 use parent qw( Module::Generic::Exception );
  1         2  
  1         6  
19 1     1   97 our $VERSION = 'v0.1.0';
20             };
21              
22             1;
23             # NOTE: POD
24             __END__
25              
26             =encoding utf-8
27              
28             =head1 NAME
29              
30             Net::API::CPAN::Exception - Meta CPAN API Exception
31              
32             =head1 SYNOPSIS
33              
34             use Net::API::CPAN::Exception;
35             my $this = Net::API::CPAN::Exception->new(
36             code => 500,
37             message => $error_message,
38             );
39             die( $this );
40              
41             my $ex = Net::API::CPAN::Exception->new({
42             code => 404,
43             type => $error_type,
44             file => '/home/joe/some/lib/Net/API/CPAN/Author.pm',
45             line => 114,
46             message => 'Invalid property provided',
47             package => 'Net::API::CPAN::Author',
48             subroutine => 'cpanid',
49             # Some optional discretionary metadata hash reference
50             cause =>
51             {
52             object => $some_object,
53             payload => $json_data,
54             },
55             });
56             print( "Error stack trace: ", $ex->stack_trace, "\n" );
57             # or
58             $author->updated( $bad_datetime ) ||
59             die( "Error in file ", $author->error->file, " at line ", $author->error->line, "\n" );
60             # or simply:
61             $author->customer_orders ||
62             die( "Error: ", $author->error, "\n" );
63             $ex->cause->payload;
64              
65             =head1 VERSION
66              
67             v0.1.0
68              
69             =head1 DESCRIPTION
70              
71             This class inherits all its methods from L<Module::Generic::Exception>
72              
73             =head1 METHODS
74              
75             Plese see L<Module::Generic::Exception> for details.
76              
77             =head1 AUTHOR
78              
79             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
80              
81             =head1 SEE ALSO
82              
83             L<Module::Generic::Exception>
84              
85             =head1 COPYRIGHT & LICENSE
86              
87             Copyright(c) 2023 DEGUEST Pte. Ltd.
88              
89             All rights reserved.
90              
91             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
92              
93             =cut