| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package XAS::Lib::Mixins::Handlers; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use XAS::Class |
|
6
|
1
|
|
|
|
|
12
|
debug => 0, |
|
7
|
|
|
|
|
|
|
version => $VERSION, |
|
8
|
|
|
|
|
|
|
base => 'XAS::Base', |
|
9
|
|
|
|
|
|
|
utils => ':validation compress', |
|
10
|
|
|
|
|
|
|
mixins => 'exit_handler exception_handler error_handler parse_exception', |
|
11
|
1
|
|
|
1
|
|
912
|
; |
|
|
1
|
|
|
|
|
2
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
14
|
|
|
|
|
|
|
# Public Methods |
|
15
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub exception_handler { |
|
18
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
19
|
0
|
|
|
|
|
|
my ($ex) = validate_params(\@_, [1]); |
|
20
|
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my ($errors, $rc) = $self->parse_exception($ex); |
|
22
|
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
$self->log->error($errors); |
|
24
|
|
|
|
|
|
|
|
|
25
|
0
|
0
|
|
|
|
|
if ($self->env->alerts) { |
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$self->alert->send($errors); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub exit_handler { |
|
34
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
35
|
0
|
|
|
|
|
|
my ($ex) = validate_params(\@_, [1]); |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my ($errors, $rc) = $self->parse_exception($ex); |
|
38
|
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$self->log->fatal($errors); |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if ($self->env->alerts) { |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
$self->alert->send($errors); |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $rc; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub error_handler { |
|
52
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
53
|
0
|
|
|
|
|
|
my ($ex) = validate_params(\@_, [1]); |
|
54
|
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my ($errors, $rc) = $self->parse_exception($ex); |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
$self->log->error($errors); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub parse_exception { |
|
62
|
0
|
|
|
0
|
0
|
|
my $self= shift; |
|
63
|
0
|
|
|
|
|
|
my ($ex) = validate_params(\@_, [1]); |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $rc = 0; |
|
66
|
0
|
|
|
|
|
|
my $errors; |
|
67
|
0
|
|
|
|
|
|
my $ref = ref($ex); |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if ($ref) { |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if ($ex->isa('Badger::Exception')) { |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $type = $ex->type; |
|
74
|
0
|
|
|
|
|
|
my $info = compress($ex->info); |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
0
|
|
|
|
|
if ($ex->match_type('dbix.class')) { |
|
|
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
if ($info =~ m/(.*) XAS::Database::Model::dbix_exception/) { |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
$rc = 1; |
|
81
|
0
|
|
|
|
|
|
$info = $1; # strip off the dbix stack dump |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} elsif ($ex->match_type('xas.lib.app.signal_handler')) { |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
die $ex; # propagate to the next level of error handlers |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
if ($ex->type =~ /pidfile\./) { |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
$rc = 2; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
$errors = $self->message('exception', $type, $info); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} else { |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
$rc = 1; |
|
102
|
0
|
|
|
|
|
|
$errors = $self->message('unexpected', compress($ex)); |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
} else { |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
$rc = 1; |
|
109
|
0
|
|
|
|
|
|
$errors = $self->message('unknownerror', compress($ex)); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
return $errors, $rc; |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
118
|
|
|
|
|
|
|
# Private Methods |
|
119
|
|
|
|
|
|
|
# ---------------------------------------------------------------------- |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |