line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WWW::Liquidweb::Lite::Error; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
17
|
use 5.006; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings FATAL => 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
2793
|
use Devel::StackTrace; |
|
1
|
|
|
|
|
9139
|
|
|
1
|
|
|
|
|
296
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
WWW::Liquidweb::Lite::Error - Error handling for WWW::Liquidweb::Lite |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head2 new |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Returns an error object |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head3 USAGE |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
ARGUMENT DESCRIPTION |
22
|
|
|
|
|
|
|
--- |
23
|
|
|
|
|
|
|
type Describes the variety of failure occurred. Potential |
24
|
|
|
|
|
|
|
values could be 'perl error', or basic http error |
25
|
|
|
|
|
|
|
codes such as '404', '500', e.t.c. |
26
|
|
|
|
|
|
|
[DEFAULTS: 'fail'] |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
category Describes what actually failed. Potential values |
29
|
|
|
|
|
|
|
could be 'http request', 'http auth', or something |
30
|
|
|
|
|
|
|
specific to your application like 'foobar api error'. |
31
|
|
|
|
|
|
|
[DEFAULTS: 'object' (assumes something is wrong with |
32
|
|
|
|
|
|
|
WWW::Liquidweb::Lite unless told otherwise)] |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
message Describes the specifics of what actually occurred for |
35
|
|
|
|
|
|
|
a user to read. |
36
|
|
|
|
|
|
|
[DEFAULTS: 'unknown'] |
37
|
|
|
|
|
|
|
--- |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new |
42
|
|
|
|
|
|
|
{ |
43
|
1
|
|
|
1
|
1
|
3
|
my $class = shift; |
44
|
1
|
50
|
|
|
|
8
|
my %args = ref($_[0]) ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
45
|
1
|
50
|
|
|
|
5
|
$args{type} = $args{type} ? $args{type} : 'fail'; |
46
|
1
|
50
|
|
|
|
4
|
$args{category} = $args{category} ? $args{category} : 'object'; |
47
|
1
|
50
|
|
|
|
5
|
$args{message} = $args{message} ? $args{message} : 'unknown'; |
48
|
1
|
|
|
|
|
6
|
my $self = { |
49
|
|
|
|
|
|
|
error_type => $args{type}, |
50
|
|
|
|
|
|
|
error_category => $args{category}, |
51
|
|
|
|
|
|
|
error_message => $args{message}, |
52
|
|
|
|
|
|
|
}; |
53
|
1
|
|
|
|
|
26
|
return bless($self, $class); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 category |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Helper method to retrieve or set the error category. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub category |
63
|
|
|
|
|
|
|
{ |
64
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
65
|
0
|
|
|
|
|
0
|
my $category = shift; |
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
|
|
|
0
|
if ($category) { |
68
|
0
|
|
|
|
|
0
|
$self->{error_category} = $category; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
return $self->{error_category}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 message |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Helper method to retrieve or set the error message. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub message |
81
|
|
|
|
|
|
|
{ |
82
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
83
|
0
|
|
|
|
|
0
|
my $message = shift; |
84
|
|
|
|
|
|
|
|
85
|
0
|
0
|
|
|
|
0
|
if ($message) { |
86
|
0
|
|
|
|
|
0
|
$self->{error_message} = $message; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
0
|
return $self->{error_message}; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 type |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Helper method to retrieve or set the error type. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub type |
99
|
|
|
|
|
|
|
{ |
100
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
101
|
0
|
|
|
|
|
0
|
my $type = shift; |
102
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
0
|
if ($type) { |
104
|
0
|
|
|
|
|
0
|
$self->{error_type} = $type; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
0
|
return $self->{error_type}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 throw |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Die, put a stack trace into the object, and return it. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head3 USAGE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Forwards to new. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
ARGUMENT DESCRIPTION |
119
|
|
|
|
|
|
|
--- |
120
|
|
|
|
|
|
|
type Describes the variety of failure occurred. Potential |
121
|
|
|
|
|
|
|
values could be 'perl error', or basic http error |
122
|
|
|
|
|
|
|
codes such as '404', '500', e.t.c. |
123
|
|
|
|
|
|
|
[DEFAULTS: 'fail'] |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
category Describes what actually failed. Potential values |
126
|
|
|
|
|
|
|
could be 'http request', 'http auth', or something |
127
|
|
|
|
|
|
|
specific to your application like 'foobar api error'. |
128
|
|
|
|
|
|
|
[DEFAULTS: 'object' (assumes something is wrong with |
129
|
|
|
|
|
|
|
WWW::Liquidweb::Lite unless told otherwise)] |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
message Describes the specifics of what actually occurred for |
132
|
|
|
|
|
|
|
a user to read. |
133
|
|
|
|
|
|
|
[DEFAULTS: 'unknown'] |
134
|
|
|
|
|
|
|
--- |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub throw |
139
|
|
|
|
|
|
|
{ |
140
|
1
|
|
|
1
|
1
|
3
|
my $object = shift; |
141
|
1
|
|
|
|
|
5
|
my $error = $object->new(@_); |
142
|
1
|
|
|
|
|
10
|
$error->{stack_trace} = Devel::StackTrace->new; |
143
|
1
|
|
|
|
|
542
|
die $error; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |