line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
440
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
3
|
|
|
|
|
|
|
package Exception::Reporter::Summarizer::ExceptionClass 0.015; |
4
|
|
|
|
|
|
|
# ABSTRACT: a summarizer for Exception::Class exceptions |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use parent 'Exception::Reporter::Summarizer'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 OVERVIEW |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod This summarizer handles only L objects. A dumped exception |
11
|
|
|
|
|
|
|
#pod will result in between one and four summaries: |
12
|
|
|
|
|
|
|
#pod |
13
|
|
|
|
|
|
|
#pod * a text summary of the exceptions full message |
14
|
|
|
|
|
|
|
#pod * if available, a dump of the exception's pid, time, uid, etc. |
15
|
|
|
|
|
|
|
#pod * if available, the stringification of the exception's stack trace |
16
|
|
|
|
|
|
|
#pod * if any fields are defined, a dump of the exception's fields |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod =cut |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
570
|
use Exception::Class 1.30; # NoContextInfo |
|
1
|
|
|
|
|
8926
|
|
|
1
|
|
|
|
|
6
|
|
21
|
1
|
|
|
1
|
|
44
|
use Try::Tiny; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
403
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub can_summarize { |
24
|
10
|
|
|
10
|
0
|
22
|
my ($self, $entry) = @_; |
25
|
10
|
|
|
10
|
|
41
|
return try { $entry->[1]->isa('Exception::Class::Base') }; |
|
10
|
|
|
|
|
248
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub summarize { |
29
|
2
|
|
|
2
|
0
|
9
|
my ($self, $entry, $internal_arg) = @_; |
30
|
2
|
|
|
|
|
19
|
my ($name, $exception, $arg) = @$entry; |
31
|
|
|
|
|
|
|
|
32
|
2
|
|
|
|
|
18
|
my $fn_base = $self->sanitize_filename($name); |
33
|
|
|
|
|
|
|
|
34
|
2
|
|
|
|
|
13
|
my $ident = $exception->error; |
35
|
2
|
|
|
|
|
25
|
($ident) = split /\n/, $ident; # only the first line, please |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Yes, I have seen the case below need handling! -- rjbs, 2012-07-03 |
38
|
2
|
50
|
|
|
|
9
|
$ident = "exception of class " . ref $exception unless length $ident; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Another option here is to dump this in a few parts: |
41
|
|
|
|
|
|
|
# * a YAML dump of the message, error, and fields |
42
|
|
|
|
|
|
|
# * a dump of the stack trace |
43
|
2
|
|
|
|
|
14
|
my @summaries = ({ |
44
|
|
|
|
|
|
|
filename => "exception-msg.txt", |
45
|
|
|
|
|
|
|
mimetype => 'text/plain', |
46
|
|
|
|
|
|
|
ident => $ident, |
47
|
|
|
|
|
|
|
body => $exception->full_message, |
48
|
|
|
|
|
|
|
}); |
49
|
|
|
|
|
|
|
|
50
|
2
|
50
|
|
|
|
42
|
if (! $exception->NoContextInfo) { |
51
|
2
|
|
|
|
|
31
|
my $context = $self->dump({ |
52
|
|
|
|
|
|
|
time => $exception->time, |
53
|
|
|
|
|
|
|
pid => $exception->pid, |
54
|
|
|
|
|
|
|
uid => $exception->uid, |
55
|
|
|
|
|
|
|
euid => $exception->euid, |
56
|
|
|
|
|
|
|
gid => $exception->gid, |
57
|
|
|
|
|
|
|
egid => $exception->egid, |
58
|
|
|
|
|
|
|
}, { basename => 'exception-context' }); |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
17
|
push @summaries, ( |
61
|
|
|
|
|
|
|
{ |
62
|
|
|
|
|
|
|
filename => "exception-stack.txt", |
63
|
|
|
|
|
|
|
mimetype => 'text/plain', |
64
|
|
|
|
|
|
|
ident => "stack trace", |
65
|
|
|
|
|
|
|
body => $exception->trace->as_string({ |
66
|
|
|
|
|
|
|
max_arg_length => 0, |
67
|
|
|
|
|
|
|
}), |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
{ |
70
|
|
|
|
|
|
|
filename => 'exception-context.txt', |
71
|
|
|
|
|
|
|
%$context, |
72
|
|
|
|
|
|
|
ident => 'exception context info', |
73
|
|
|
|
|
|
|
}, |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
2
|
50
|
|
|
|
887
|
if ($exception->Fields) { |
78
|
0
|
|
|
|
|
0
|
my $hash = {}; |
79
|
0
|
|
|
|
|
0
|
for my $field ($exception->Fields) { |
80
|
0
|
|
|
|
|
0
|
$hash->{ $field } = $exception->$field; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
0
|
my $fields = $self->dump($hash, { basename => 'exception-fields' }); |
84
|
0
|
|
|
|
|
0
|
push @summaries, { |
85
|
|
|
|
|
|
|
filename => "exception-fields.txt", |
86
|
|
|
|
|
|
|
%$fields, |
87
|
|
|
|
|
|
|
ident => "exception fields", |
88
|
|
|
|
|
|
|
}; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
2
|
|
|
|
|
18
|
return @summaries; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |