line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RPC::ExtDirect::Exception; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
951
|
use strict; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
168
|
|
4
|
7
|
|
|
7
|
|
23
|
use warnings; |
|
7
|
|
|
|
|
7
|
|
|
7
|
|
|
|
|
163
|
|
5
|
7
|
|
|
7
|
|
36
|
no warnings 'uninitialized'; ## no critic |
|
7
|
|
|
|
|
7
|
|
|
7
|
|
|
|
|
256
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
20
|
use Carp; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
348
|
|
8
|
|
|
|
|
|
|
|
9
|
7
|
|
|
7
|
|
1379
|
use RPC::ExtDirect::Util::Accessor; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
151
|
|
10
|
7
|
|
|
7
|
|
752
|
use RPC::ExtDirect::Util qw/ clean_error_message get_caller_info /; |
|
7
|
|
|
|
|
7
|
|
|
7
|
|
|
|
|
1894
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
### PUBLIC CLASS METHOD (CONSTRUCTOR) ### |
13
|
|
|
|
|
|
|
# |
14
|
|
|
|
|
|
|
# Initializes new instance of Exception. |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
25
|
|
|
25
|
0
|
1376
|
my ($class, $arg) = @_; |
19
|
|
|
|
|
|
|
|
20
|
25
|
|
|
|
|
40
|
my $where = $arg->{where}; |
21
|
25
|
|
|
|
|
26
|
my $message = $arg->{message}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $self = bless { |
24
|
|
|
|
|
|
|
debug => $arg->{debug}, |
25
|
|
|
|
|
|
|
action => $arg->{action}, |
26
|
|
|
|
|
|
|
method => $arg->{method}, |
27
|
|
|
|
|
|
|
tid => $arg->{tid}, |
28
|
|
|
|
|
|
|
verbose => $arg->{verbose}, |
29
|
25
|
|
|
|
|
102
|
}, $class; |
30
|
|
|
|
|
|
|
|
31
|
25
|
|
|
|
|
50
|
$self->_set_error($message, $where); |
32
|
|
|
|
|
|
|
|
33
|
25
|
|
|
|
|
80
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
### PUBLIC INSTANCE METHOD ### |
37
|
|
|
|
|
|
|
# |
38
|
|
|
|
|
|
|
# A stub for duck typing. Always returns failure. |
39
|
|
|
|
|
|
|
# |
40
|
|
|
|
|
|
|
|
41
|
18
|
|
|
18
|
0
|
13346
|
sub run { '' } |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
### PUBLIC INSTANCE METHOD ### |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
# Returns exception hashref; named so for duck typing. |
46
|
|
|
|
|
|
|
# |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub result { |
49
|
25
|
|
|
25
|
0
|
9314
|
my ($self) = @_; |
50
|
|
|
|
|
|
|
|
51
|
25
|
|
|
|
|
43
|
return $self->_get_exception_hashref(); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
### PUBLIC INSTANCE METHODS ### |
55
|
|
|
|
|
|
|
# |
56
|
|
|
|
|
|
|
# Simple read-write accessors |
57
|
|
|
|
|
|
|
# |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
RPC::ExtDirect::Util::Accessor::mk_accessors( |
60
|
|
|
|
|
|
|
simple => [qw/ |
61
|
|
|
|
|
|
|
debug action method tid where message verbose |
62
|
|
|
|
|
|
|
/], |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
############## PRIVATE METHODS BELOW ############## |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
### PRIVATE INSTANCE METHOD ### |
68
|
|
|
|
|
|
|
# |
69
|
|
|
|
|
|
|
# Sets internal error condition and message |
70
|
|
|
|
|
|
|
# |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _set_error { |
73
|
25
|
|
|
25
|
|
28
|
my ($self, $message, $where) = @_; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Store the information |
76
|
25
|
100
|
|
|
|
62
|
$self->{where} = defined $where ? $where : get_caller_info(3); |
77
|
25
|
|
|
|
|
29
|
$self->{message} = $message; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Ensure fall through for caller methods |
80
|
25
|
|
|
|
|
29
|
return !1; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
### PRIVATE INSTANCE METHOD ### |
84
|
|
|
|
|
|
|
# |
85
|
|
|
|
|
|
|
# Returns exception hashref |
86
|
|
|
|
|
|
|
# |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub _get_exception_hashref { |
89
|
25
|
|
|
25
|
|
27
|
my ($self) = @_; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# If debug flag is not set, return generic message. This is for |
92
|
|
|
|
|
|
|
# compatibility with Ext.Direct specification. |
93
|
25
|
|
|
|
|
21
|
my ($where, $message); |
94
|
|
|
|
|
|
|
|
95
|
25
|
100
|
100
|
|
|
567
|
if ( $self->debug || $self->verbose ) { |
96
|
19
|
|
|
|
|
357
|
$where = $self->where; |
97
|
19
|
|
|
|
|
326
|
$message = $self->message; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
else { |
100
|
6
|
|
|
|
|
11
|
$where = 'ExtDirect'; |
101
|
6
|
|
|
|
|
7
|
$message = 'An error has occured while processing request'; |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Format the hashref |
105
|
25
|
|
|
|
|
473
|
my $exception_ref = { |
106
|
|
|
|
|
|
|
type => 'exception', |
107
|
|
|
|
|
|
|
action => $self->action, |
108
|
|
|
|
|
|
|
method => $self->method, |
109
|
|
|
|
|
|
|
tid => $self->tid, |
110
|
|
|
|
|
|
|
where => $where, |
111
|
|
|
|
|
|
|
message => $message, |
112
|
|
|
|
|
|
|
}; |
113
|
|
|
|
|
|
|
|
114
|
25
|
|
|
|
|
71
|
return $exception_ref; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |