| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: Exceptions.pm,v 1.4 2006/02/27 21:43:59 toni Exp $ |
|
2
|
|
|
|
|
|
|
package Luka::Exceptions; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
$VERSION = "1.02"; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Luka::Exceptions - exception classes |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Luka::Exceptions; |
|
13
|
|
|
|
|
|
|
use Error qw(:try); |
|
14
|
|
|
|
|
|
|
push @Exception::Class::Base::ISA, 'Error' |
|
15
|
|
|
|
|
|
|
unless Exception::Class::Base->isa('Error'); |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
try { |
|
18
|
|
|
|
|
|
|
# some external library that dies unexpectedly |
|
19
|
|
|
|
|
|
|
do_something(); |
|
20
|
|
|
|
|
|
|
} |
|
21
|
|
|
|
|
|
|
catch Error with { |
|
22
|
|
|
|
|
|
|
# this will catch errors of any type |
|
23
|
|
|
|
|
|
|
$e = shift; |
|
24
|
|
|
|
|
|
|
throw Luka::Exception::Program( error => $e, show_trace => 1 ); |
|
25
|
|
|
|
|
|
|
}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This class provides custom exceptions for Luka. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 EXCEPTION types |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
There are three exceptions that can be thrown: |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=over |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item Luka::Exception::External |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
network and OS errors (connectivity, file system); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item Luka::Exception::User |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
user interaction related errors |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item Luka::Exception::Program |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
internal program errors |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=back |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 EXCEPTION attributes |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
All classes have the same fields: error, context, args, path, |
|
54
|
|
|
|
|
|
|
severity, conf, show_trace. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 error |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Error string thrown by library, in perl I<$!> or I<$@>. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 context |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Explanation of exception that ought to out error in context for the |
|
63
|
|
|
|
|
|
|
person dealing with it who doesn't necessarily know much about the |
|
64
|
|
|
|
|
|
|
script. For example, if an FTP connection fails we should report: |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
FTP error: geting SpecialData feed from Someone failed. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
and not anything similar to: |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
FTP connection failed. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Why? Because to someone dealing with the problem, but not familiar |
|
73
|
|
|
|
|
|
|
with the application, FTP connection failed says nothing new - usualy, |
|
74
|
|
|
|
|
|
|
that info is already present in the library error, which should always |
|
75
|
|
|
|
|
|
|
be in the I field of the exception thrown. So, instead of |
|
76
|
|
|
|
|
|
|
replicating information provided by the machine, give information |
|
77
|
|
|
|
|
|
|
known only to you, developer: |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=over |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item object/component dealt with |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item desired outcome and its importance of its functionality |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item remote side involved |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 args |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Arguments that might be needed for resolving the reasons for failure: |
|
92
|
|
|
|
|
|
|
either those provided to the subroutine from which exception is thrown |
|
93
|
|
|
|
|
|
|
or those supplied to the external library whose error we're dealing |
|
94
|
|
|
|
|
|
|
with. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head2 show_trace |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
If assigned value 1, this option will include stack trace. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 severity |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Severity level of the error thrown. See TODO section in L. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 id |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Id of the error thrown. Can be used as a namespace for tracking errors |
|
107
|
|
|
|
|
|
|
and linking to appropriate documentation. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 conf |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Configuration used for L system. Used for testing only. |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L, L |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
|
118
|
|
|
|
|
|
|
|
|
119
|
2
|
|
|
2
|
|
193
|
BEGIN { $Exception::Class::BASE_EXC_CLASS = 'Luka::ExceptionBase'; } |
|
120
|
|
|
|
|
|
|
|
|
121
|
2
|
|
|
|
|
38
|
use Exception::Class ( Luka::Exception, |
|
122
|
|
|
|
|
|
|
Luka::Exception::External => |
|
123
|
|
|
|
|
|
|
{ |
|
124
|
|
|
|
|
|
|
isa => 'Luka::Exception', |
|
125
|
|
|
|
|
|
|
description => 'external exception', |
|
126
|
|
|
|
|
|
|
fields => [ 'id', 'context', 'args', 'path', 'severity', 'conf' ], |
|
127
|
|
|
|
|
|
|
}, |
|
128
|
|
|
|
|
|
|
Luka::Exception::User => |
|
129
|
|
|
|
|
|
|
{ |
|
130
|
|
|
|
|
|
|
isa => 'Luka::Exception', |
|
131
|
|
|
|
|
|
|
description => 'user related exception', |
|
132
|
|
|
|
|
|
|
fields => [ 'id', 'context', 'args', 'path', 'severity', 'conf' ], |
|
133
|
|
|
|
|
|
|
}, |
|
134
|
|
|
|
|
|
|
Luka::Exception::Program => |
|
135
|
|
|
|
|
|
|
{ |
|
136
|
|
|
|
|
|
|
isa => 'Luka::Exception', |
|
137
|
|
|
|
|
|
|
description => 'internal programming exception', |
|
138
|
|
|
|
|
|
|
fields => [ 'id', 'context', 'args', 'path', 'severity' , 'conf'], |
|
139
|
|
|
|
|
|
|
}, |
|
140
|
2
|
|
|
2
|
|
1751
|
); |
|
|
2
|
|
|
|
|
38365
|
|
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHOR |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Toni Prug |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Copyright (c) 2006. Toni Prug. All rights reserved. |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
154
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
|
155
|
|
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or (at |
|
156
|
|
|
|
|
|
|
your option) any later version. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but |
|
159
|
|
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
160
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
161
|
|
|
|
|
|
|
General Public License for more details. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
164
|
|
|
|
|
|
|
along with this program; if not, write to the Free Software |
|
165
|
|
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
166
|
|
|
|
|
|
|
USA |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
See L |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=cut |