| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Ekahau::ErrHandler; |
|
2
|
|
|
|
|
|
|
our $VERSION = '0.001'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# Written by Scott Gifford |
|
5
|
|
|
|
|
|
|
# Copyright (C) 2005 The Regents of the University of Michigan. |
|
6
|
|
|
|
|
|
|
# See the file LICENSE included with the distribution for license |
|
7
|
|
|
|
|
|
|
# information. |
|
8
|
|
|
|
|
|
|
|
|
9
|
6
|
|
|
6
|
|
41
|
use warnings; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
202
|
|
|
10
|
6
|
|
|
6
|
|
30
|
use strict; |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
184
|
|
|
11
|
6
|
|
|
6
|
|
36
|
use Carp; |
|
|
6
|
|
|
|
|
10
|
|
|
|
6
|
|
|
|
|
727
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Ekahau::ErrHandler - Internal class used to unify error handling across Ekahau modules |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This class provides consistent error-handling methods across all of |
|
21
|
|
|
|
|
|
|
the Ekahau classes. It is designed for internal use only, and so is |
|
22
|
|
|
|
|
|
|
not documented. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
6
|
|
|
6
|
|
91
|
use constant EHCLASS => 'Ekahau::ErrHandler'; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
742
|
|
|
28
|
6
|
|
|
6
|
|
38
|
use constant INTCLASS => EHCLASS.'::Internal'; |
|
|
6
|
|
|
|
|
9
|
|
|
|
6
|
|
|
|
|
8374
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub errhandler_new |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
33
|
0
|
|
|
|
|
|
my($objclass,%p) = @_; |
|
34
|
0
|
0
|
|
|
|
|
$objclass |
|
35
|
|
|
|
|
|
|
or croak "usage: Ekahau::ErrHandler->errhandler_new($class,[%params])"; |
|
36
|
0
|
|
|
|
|
|
my $self = {objclass => $objclass}; |
|
37
|
0
|
|
|
|
|
|
bless $self, 'Ekahau::ErrHandler::Internal'; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# If these are undef defaults will be set |
|
40
|
0
|
|
|
|
|
|
$self->set_errhandler($p{ErrorHandler}); |
|
41
|
0
|
|
|
|
|
|
$self->set_errholder($p{ErrorHolder}); |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
$self; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub errhandler_constructed |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
49
|
0
|
0
|
|
|
|
|
my $errobj = $self->ERROBJ |
|
50
|
|
|
|
|
|
|
or croak "Couldn't get error object from $self"; |
|
51
|
0
|
|
|
|
|
|
$errobj->errhandler_constructed(@_); |
|
52
|
0
|
|
|
|
|
|
$self; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub errhandler_deconstructed |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
58
|
0
|
0
|
|
|
|
|
my $errobj = $self->ERROBJ |
|
59
|
|
|
|
|
|
|
or croak "Couldn't get error object from $self"; |
|
60
|
0
|
|
|
|
|
|
$errobj->errhandler_constructed(@_); |
|
61
|
0
|
|
|
|
|
|
$self; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub set_errhandler |
|
65
|
|
|
|
|
|
|
{ |
|
66
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
67
|
0
|
0
|
|
|
|
|
if (ref $self) |
|
68
|
|
|
|
|
|
|
{ |
|
69
|
|
|
|
|
|
|
# Object |
|
70
|
0
|
0
|
|
|
|
|
my $errobj = $self->ERROBJ |
|
71
|
|
|
|
|
|
|
or croak "Couldn't get error object from $self"; |
|
72
|
0
|
|
|
|
|
|
return $errobj->set_errhandler(@_); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
else |
|
75
|
|
|
|
|
|
|
{ |
|
76
|
0
|
|
|
|
|
|
return Ekahau::ErrHandler::Internal->class_errhandler($self,@_); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub set_errholder |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
83
|
0
|
0
|
|
|
|
|
if (ref $self) |
|
84
|
|
|
|
|
|
|
{ |
|
85
|
|
|
|
|
|
|
# Object |
|
86
|
0
|
0
|
|
|
|
|
my $errobj = $self->ERROBJ |
|
87
|
|
|
|
|
|
|
or croak "Couldn't get error object from $self"; |
|
88
|
0
|
|
|
|
|
|
return $errobj->set_errholder(@_); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
else |
|
91
|
|
|
|
|
|
|
{ |
|
92
|
0
|
|
|
|
|
|
return Ekahau::ErrHandler::Internal->class_errholder($self,@_); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub reterr |
|
97
|
|
|
|
|
|
|
{ |
|
98
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
99
|
0
|
0
|
|
|
|
|
my $errobj = $self->ERROBJ |
|
100
|
|
|
|
|
|
|
or croak "Couldn't get error object from $self"; |
|
101
|
0
|
|
|
|
|
|
$errobj->reterr(@_); |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub lasterr |
|
105
|
|
|
|
|
|
|
{ |
|
106
|
0
|
|
|
0
|
0
|
|
my $arg = shift; |
|
107
|
0
|
0
|
|
|
|
|
if (ref $arg) |
|
108
|
|
|
|
|
|
|
{ |
|
109
|
|
|
|
|
|
|
# Object |
|
110
|
0
|
0
|
|
|
|
|
my $errobj = $arg->ERROBJ |
|
111
|
|
|
|
|
|
|
or croak "Couldn't get error object from '$arg'"; |
|
112
|
0
|
|
|
|
|
|
return $errobj->lasterr(@_); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
else |
|
115
|
|
|
|
|
|
|
{ |
|
116
|
0
|
|
|
|
|
|
return Ekahau::ErrHandler::Internal->last_classerr($arg); |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# Alias for lasterr. |
|
121
|
|
|
|
|
|
|
sub lasterror |
|
122
|
|
|
|
|
|
|
{ |
|
123
|
0
|
|
|
0
|
0
|
|
goto &lasterr; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
package Ekahau::ErrHandler::Internal; |
|
127
|
|
|
|
|
|
|
|
|
128
|
6
|
|
|
6
|
|
56
|
use constant EHCLASS => Ekahau::ErrHandler::EHCLASS; |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
6125
|
|
|
129
|
6
|
|
|
6
|
|
59
|
use constant INTCLASS => Ekahau::ErrHandler::INTCLASS; |
|
|
6
|
|
|
|
|
12
|
|
|
|
6
|
|
|
|
|
15580
|
|
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
our %class_errstr; |
|
132
|
|
|
|
|
|
|
our %classdefs; |
|
133
|
|
|
|
|
|
|
our %defs; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub errhandler_constructed |
|
136
|
|
|
|
|
|
|
{ |
|
137
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
138
|
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
$self->{constructed} = 1; |
|
140
|
0
|
0
|
|
|
|
|
$self->set_errholder(undef) |
|
141
|
|
|
|
|
|
|
unless (!$self->{custom_errstr}); |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub errhandler_deconstructed |
|
145
|
|
|
|
|
|
|
{ |
|
146
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
147
|
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
$self->{constructed} = 0; |
|
149
|
0
|
0
|
|
|
|
|
$self->set_errholder(undef) |
|
150
|
|
|
|
|
|
|
unless (!$self->{custom_errstr}); |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub set_errhandler |
|
156
|
|
|
|
|
|
|
{ |
|
157
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
158
|
0
|
|
|
|
|
|
my($handler)=@_; |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
0
|
|
|
|
|
if ($handler) |
|
161
|
|
|
|
|
|
|
{ |
|
162
|
0
|
|
|
|
|
|
$self->{handler} = $handler; |
|
163
|
0
|
|
|
|
|
|
$self->{custom_handler} = 1; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
else |
|
166
|
|
|
|
|
|
|
{ |
|
167
|
0
|
0
|
0
|
|
|
|
if ($classdefs{$self->{objclass}} and $classdefs{$self->{objclass}}{handler}) |
|
|
|
0
|
0
|
|
|
|
|
|
168
|
|
|
|
|
|
|
{ |
|
169
|
0
|
|
|
|
|
|
$self->{handler} = $classdefs{$self->{objclass}}{handler}; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
elsif ($classdefs{EHCLASS()} and $classdefs{EHCLASS()}{handler}) |
|
172
|
|
|
|
|
|
|
{ |
|
173
|
0
|
|
|
|
|
|
$self->{handler} = $classdefs{EHCLASS()}{handler}; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
else |
|
176
|
|
|
|
|
|
|
{ |
|
177
|
0
|
|
|
|
|
|
$self->{handler} =\&default_errhandler; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
0
|
|
|
|
|
|
$self->{custom_handler} = 0; |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub set_errholder |
|
184
|
|
|
|
|
|
|
{ |
|
185
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
186
|
0
|
|
|
|
|
|
my($holder)=@_; |
|
187
|
|
|
|
|
|
|
|
|
188
|
0
|
0
|
|
|
|
|
if ($holder) |
|
189
|
|
|
|
|
|
|
{ |
|
190
|
0
|
|
|
|
|
|
$self->{errstr} = $holder; |
|
191
|
0
|
|
|
|
|
|
$self->{custom_errstr} = 1; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
else |
|
194
|
|
|
|
|
|
|
{ |
|
195
|
0
|
0
|
|
|
|
|
if ($self->{constructed}) |
|
196
|
|
|
|
|
|
|
{ |
|
197
|
|
|
|
|
|
|
# Construct a lexical scalar |
|
198
|
0
|
|
|
|
|
|
my $errstr = "unknown error"; |
|
199
|
0
|
|
|
|
|
|
$self->{errstr} = \$errstr; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
else |
|
202
|
|
|
|
|
|
|
{ |
|
203
|
0
|
0
|
|
|
|
|
if (!$class_errstr{$self->{objclass}}) |
|
204
|
|
|
|
|
|
|
{ |
|
205
|
0
|
|
|
|
|
|
my $errstr = "unknown error"; |
|
206
|
0
|
|
|
|
|
|
$class_errstr{$self->{objclass}} = \$errstr; |
|
207
|
|
|
|
|
|
|
} |
|
208
|
0
|
|
|
|
|
|
$self->{errstr} = $class_errstr{$self->{objclass}}; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
|
|
211
|
0
|
|
|
|
|
|
$self->{custom_errstr} = 0; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub reterr |
|
216
|
|
|
|
|
|
|
{ |
|
217
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
218
|
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
$self->{handler}->($self,@_); |
|
220
|
0
|
|
|
|
|
|
undef; |
|
221
|
|
|
|
|
|
|
} |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
sub lasterr |
|
224
|
|
|
|
|
|
|
{ |
|
225
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
226
|
0
|
|
|
|
|
|
return ${$self->{errstr}}; |
|
|
0
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub last_classerr |
|
230
|
|
|
|
|
|
|
{ |
|
231
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
232
|
0
|
|
|
|
|
|
my($objclass)=@_; |
|
233
|
0
|
|
|
|
|
|
return ${$class_errstr{$objclass}}; |
|
|
0
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub default_errhandler |
|
237
|
|
|
|
|
|
|
{ |
|
238
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
239
|
0
|
|
|
|
|
|
my $errmsg = join("",@_); |
|
240
|
0
|
|
|
|
|
|
my $errholder = $self->{errstr}; |
|
241
|
0
|
0
|
|
|
|
|
ref $errholder |
|
242
|
|
|
|
|
|
|
or die "Fatal error handling non-fatal error: $errmsg"; |
|
243
|
0
|
|
|
|
|
|
$$errholder = $errmsg; |
|
244
|
0
|
|
|
|
|
|
1; |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
sub class_errholder |
|
248
|
|
|
|
|
|
|
{ |
|
249
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
250
|
0
|
|
|
|
|
|
my($objclass,$holder)=@_; |
|
251
|
|
|
|
|
|
|
|
|
252
|
0
|
|
|
|
|
|
$classdefs{$objclass}{holder}=$holder; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
sub class_errhandler |
|
256
|
|
|
|
|
|
|
{ |
|
257
|
0
|
|
|
0
|
|
|
my $class = shift; |
|
258
|
0
|
|
|
|
|
|
my($objclass,$handler)=@_; |
|
259
|
|
|
|
|
|
|
|
|
260
|
0
|
|
|
|
|
|
$classdefs{$objclass}{handler}=$handler; |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=head1 AUTHOR |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Scott Gifford Egifford@umich.eduE, Esgifford@suspectclass.comE |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
Copyright (C) 2005 The Regents of the University of Michigan. |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
See the file LICENSE included with the distribution for license |
|
270
|
|
|
|
|
|
|
information. |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=cut |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
1; |