line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::Rest::Generic::Error; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
1297
|
use 5.006; |
|
8
|
|
|
|
|
29
|
|
|
8
|
|
|
|
|
308
|
|
4
|
8
|
|
|
8
|
|
47
|
use strict; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
299
|
|
5
|
8
|
|
|
8
|
|
41
|
use warnings FATAL => 'all'; |
|
8
|
|
|
|
|
22
|
|
|
8
|
|
|
|
|
2040
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Net::Rest::Generic::Error - Error handling for Net::Rest::Generic |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head2 throw() |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Used like ->new to give an error object. |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head3 USAGE |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
ARGUMENT DESCRIPTION |
20
|
|
|
|
|
|
|
--- |
21
|
|
|
|
|
|
|
type Describes the variety of failure occurred. Potential |
22
|
|
|
|
|
|
|
values could be 'perl error', or basic http error |
23
|
|
|
|
|
|
|
codes such as '404', '500', e.t.c. |
24
|
|
|
|
|
|
|
~ Default: 'fail' |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
category Describes what actually failed. Potential values |
27
|
|
|
|
|
|
|
could be 'http request', 'http auth', or something |
28
|
|
|
|
|
|
|
specific to your application like 'foobar api error'. |
29
|
|
|
|
|
|
|
~ Default: 'object' (assumes something is wrong with |
30
|
|
|
|
|
|
|
Net::Rest::Generic unless told otherwise) |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
message Describes the specifics of what actually occurred for |
33
|
|
|
|
|
|
|
a user to read. |
34
|
|
|
|
|
|
|
~ Default: 'unknown' |
35
|
|
|
|
|
|
|
--- |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub throw { |
40
|
5
|
|
|
5
|
1
|
1282
|
my $class = shift; |
41
|
5
|
100
|
|
|
|
28
|
my %args = ref($_[0]) ? %{$_[0]} : @_; |
|
1
|
|
|
|
|
6
|
|
42
|
5
|
100
|
|
|
|
21
|
$args{type} = $args{type} ? $args{type} : 'fail'; |
43
|
5
|
100
|
|
|
|
17
|
$args{category} = $args{category} ? $args{category} : 'object'; |
44
|
5
|
100
|
|
|
|
14
|
$args{message} = $args{message} ? $args{message} : 'unknown'; |
45
|
5
|
|
|
|
|
23
|
my $self = { |
46
|
|
|
|
|
|
|
error_type => $args{type}, |
47
|
|
|
|
|
|
|
error_category => $args{category}, |
48
|
|
|
|
|
|
|
error_message => $args{message}, |
49
|
|
|
|
|
|
|
}; |
50
|
5
|
|
|
|
|
28
|
return bless $self, $class; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 category() |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Helper method to retrieve the category of the current error object. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub category { |
60
|
4
|
|
|
4
|
1
|
411
|
return shift->{error_category}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 message() |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Helper method to retrieve the message of the current error object. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub message { |
70
|
3
|
|
|
3
|
1
|
1242
|
return shift->{error_message}; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 type() |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Helper method to retrieve the type of the current error object. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub type { |
80
|
3
|
|
|
3
|
1
|
392
|
return shift->{error_type}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |