line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Params::CallbackRequest::Exceptions; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
44
|
use strict; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
248
|
|
4
|
7
|
|
|
7
|
|
38
|
use vars qw($VERSION); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
1010
|
|
5
|
|
|
|
|
|
|
$VERSION = '1.20'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Exception::Class ( |
8
|
7
|
|
|
|
|
152
|
'Params::Callback::Exception' => { |
9
|
|
|
|
|
|
|
description => 'Params::Callback exception', |
10
|
|
|
|
|
|
|
alias => 'throw_cb' |
11
|
|
|
|
|
|
|
}, |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
'Params::Callback::Exception::InvalidKey' => { |
14
|
|
|
|
|
|
|
isa => 'Params::Callback::Exception', |
15
|
|
|
|
|
|
|
description => 'No callback found for callback key', |
16
|
|
|
|
|
|
|
alias => 'throw_bad_key', |
17
|
|
|
|
|
|
|
fields => [qw(callback_key)] |
18
|
|
|
|
|
|
|
}, |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
'Params::Callback::Exception::Execution' => { |
21
|
|
|
|
|
|
|
isa => 'Params::Callback::Exception', |
22
|
|
|
|
|
|
|
description => 'Error thrown by callback', |
23
|
|
|
|
|
|
|
alias => 'throw_cb_exec', |
24
|
|
|
|
|
|
|
fields => [qw(callback_key callback_error)] |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
'Params::Callback::Exception::Params' => { |
28
|
|
|
|
|
|
|
isa => 'Params::Callback::Exception', |
29
|
|
|
|
|
|
|
description => 'Invalid parameter', |
30
|
|
|
|
|
|
|
alias => 'throw_bad_params', |
31
|
|
|
|
|
|
|
fields => [qw(param)] |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
'Params::Callback::Exception::Abort' => { |
35
|
|
|
|
|
|
|
isa => 'Params::Callback::Exception', |
36
|
|
|
|
|
|
|
fields => [qw(aborted_value)], |
37
|
|
|
|
|
|
|
alias => 'throw_abort', |
38
|
|
|
|
|
|
|
description => 'a callback called abort()' |
39
|
|
|
|
|
|
|
}, |
40
|
7
|
|
|
7
|
|
6351
|
); |
|
7
|
|
|
|
|
115692
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub import { |
43
|
16
|
|
|
16
|
|
82
|
my ($class, %args) = @_; |
44
|
|
|
|
|
|
|
|
45
|
16
|
|
|
|
|
110
|
my $caller = caller; |
46
|
16
|
50
|
|
|
|
112
|
if ($args{abbr}) { |
47
|
16
|
|
|
|
|
25
|
foreach my $name (@{$args{abbr}}) { |
|
16
|
|
|
|
|
50
|
|
48
|
7
|
|
|
7
|
|
39336
|
no strict 'refs'; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
633
|
|
49
|
30
|
|
|
|
|
116
|
die "Unknown exception abbreviation '$name'" |
50
|
30
|
50
|
|
|
|
38
|
unless defined &{$name}; |
51
|
30
|
|
|
|
|
42
|
*{"${caller}::$name"} = \&{$name}; |
|
30
|
|
|
|
|
201
|
|
|
30
|
|
|
|
|
60
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
7
|
|
|
7
|
|
36
|
no strict 'refs'; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
1761
|
|
56
|
16
|
|
|
|
|
40
|
*{"${caller}::isa_cb_exception"} = \&isa_cb_exception; |
|
16
|
|
|
|
|
88
|
|
57
|
16
|
|
|
|
|
34
|
*{"${caller}::rethrow_exception"} = \&rethrow_exception; |
|
16
|
|
|
|
|
582
|
|
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub isa_cb_exception ($;$) { |
61
|
20
|
|
|
20
|
1
|
45
|
my ($err, $name) = @_; |
62
|
20
|
50
|
|
|
|
50
|
return unless defined $err; |
63
|
|
|
|
|
|
|
|
64
|
20
|
|
|
|
|
35
|
my $class = "Params::Callback::Exception"; |
65
|
20
|
50
|
|
|
|
60
|
$class .= "::$name" if $name; |
66
|
20
|
|
|
|
|
245
|
return UNIVERSAL::isa($err, $class); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub rethrow_exception ($) { |
70
|
4
|
50
|
|
4
|
1
|
18
|
my $err = shift or return; |
71
|
4
|
100
|
|
|
|
54
|
$err->rethrow if UNIVERSAL::can($err, 'rethrow'); |
72
|
1
|
50
|
|
|
|
11
|
die $err if ref $err; |
73
|
0
|
|
|
|
|
|
Params::Callback::Exception->throw(error => $err); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
__END__ |