| Filename | /usr/lib64/perl5/vendor_perl/5.16.0/XML/SAX/Exception.pm |
| Statements | Executed 14 statements in 2.84ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 58µs | 58µs | XML::SAX::Exception::BEGIN@2 |
| 1 | 1 | 1 | 55µs | 314µs | XML::SAX::Exception::BEGIN@13 |
| 1 | 1 | 1 | 52µs | 204µs | XML::SAX::Exception::BEGIN@11 |
| 1 | 1 | 1 | 52µs | 268µs | XML::SAX::Exception::BEGIN@8 |
| 1 | 1 | 1 | 49µs | 142µs | XML::SAX::Exception::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | XML::SAX::Exception::new |
| 0 | 0 | 0 | 0s | 0s | XML::SAX::Exception::stackstring |
| 0 | 0 | 0 | 0s | 0s | XML::SAX::Exception::stacktrace |
| 0 | 0 | 0 | 0s | 0s | XML::SAX::Exception::stringify |
| 0 | 0 | 0 | 0s | 0s | XML::SAX::Exception::throw |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package XML::SAX::Exception; | ||||
| 2 | # spent 58µs within XML::SAX::Exception::BEGIN@2 which was called:
# once (58µs+0s) by XML::SAX::ParserFactory::BEGIN@12 at line 4 | ||||
| 3 | 1 | 36µs | $XML::SAX::Exception::VERSION = '1.08'; | ||
| 4 | 1 | 114µs | 1 | 58µs | } # spent 58µs making 1 call to XML::SAX::Exception::BEGIN@2 |
| 5 | |||||
| 6 | 2 | 169µs | 2 | 236µs | # spent 142µs (49+94) within XML::SAX::Exception::BEGIN@6 which was called:
# once (49µs+94µs) by XML::SAX::ParserFactory::BEGIN@12 at line 6 # spent 142µs making 1 call to XML::SAX::Exception::BEGIN@6
# spent 94µs making 1 call to strict::import |
| 7 | |||||
| 8 | 1 | 35µs | 1 | 217µs | # spent 268µs (52+217) within XML::SAX::Exception::BEGIN@8 which was called:
# once (52µs+217µs) by XML::SAX::ParserFactory::BEGIN@12 at line 9 # spent 217µs making 1 call to overload::import |
| 9 | 1 | 127µs | 1 | 268µs | 'fallback' => 1; # spent 268µs making 1 call to XML::SAX::Exception::BEGIN@8 |
| 10 | |||||
| 11 | 2 | 151µs | 2 | 356µs | # spent 204µs (52+152) within XML::SAX::Exception::BEGIN@11 which was called:
# once (52µs+152µs) by XML::SAX::ParserFactory::BEGIN@12 at line 11 # spent 204µs making 1 call to XML::SAX::Exception::BEGIN@11
# spent 152µs making 1 call to vars::import |
| 12 | |||||
| 13 | 2 | 2.10ms | 2 | 573µs | # spent 314µs (55+259) within XML::SAX::Exception::BEGIN@13 which was called:
# once (55µs+259µs) by XML::SAX::ParserFactory::BEGIN@12 at line 13 # spent 314µs making 1 call to XML::SAX::Exception::BEGIN@13
# spent 259µs making 1 call to Exporter::import |
| 14 | |||||
| 15 | 1 | 7µs | $StackTrace = $ENV{XML_DEBUG} || 0; | ||
| 16 | |||||
| 17 | # Other exception classes: | ||||
| 18 | |||||
| 19 | 1 | 39µs | @XML::SAX::Exception::NotRecognized::ISA = ('XML::SAX::Exception'); | ||
| 20 | 1 | 21µs | @XML::SAX::Exception::NotSupported::ISA = ('XML::SAX::Exception'); | ||
| 21 | 1 | 19µs | @XML::SAX::Exception::Parse::ISA = ('XML::SAX::Exception'); | ||
| 22 | |||||
| 23 | |||||
| 24 | sub throw { | ||||
| 25 | my $class = shift; | ||||
| 26 | if (ref($class)) { | ||||
| 27 | die $class; | ||||
| 28 | } | ||||
| 29 | die $class->new(@_); | ||||
| 30 | } | ||||
| 31 | |||||
| 32 | sub new { | ||||
| 33 | my $class = shift; | ||||
| 34 | my %opts = @_; | ||||
| 35 | confess "Invalid options: " . join(', ', keys %opts) unless exists $opts{Message}; | ||||
| 36 | |||||
| 37 | bless { ($StackTrace ? (StackTrace => stacktrace()) : ()), %opts }, | ||||
| 38 | $class; | ||||
| 39 | } | ||||
| 40 | |||||
| 41 | sub stringify { | ||||
| 42 | my $self = shift; | ||||
| 43 | local $^W; | ||||
| 44 | my $error; | ||||
| 45 | if (exists $self->{LineNumber}) { | ||||
| 46 | $error = $self->{Message} . " [Ln: " . $self->{LineNumber} . | ||||
| 47 | ", Col: " . $self->{ColumnNumber} . "]"; | ||||
| 48 | } | ||||
| 49 | else { | ||||
| 50 | $error = $self->{Message}; | ||||
| 51 | } | ||||
| 52 | if ($StackTrace) { | ||||
| 53 | $error .= stackstring($self->{StackTrace}); | ||||
| 54 | } | ||||
| 55 | $error .= "\n"; | ||||
| 56 | return $error; | ||||
| 57 | } | ||||
| 58 | |||||
| 59 | sub stacktrace { | ||||
| 60 | my $i = 2; | ||||
| 61 | my @fulltrace; | ||||
| 62 | while (my @trace = caller($i++)) { | ||||
| 63 | my %hash; | ||||
| 64 | @hash{qw(Package Filename Line)} = @trace[0..2]; | ||||
| 65 | push @fulltrace, \%hash; | ||||
| 66 | } | ||||
| 67 | return \@fulltrace; | ||||
| 68 | } | ||||
| 69 | |||||
| 70 | sub stackstring { | ||||
| 71 | my $stacktrace = shift; | ||||
| 72 | my $string = "\nFrom:\n"; | ||||
| 73 | foreach my $current (@$stacktrace) { | ||||
| 74 | $string .= $current->{Filename} . " Line: " . $current->{Line} . "\n"; | ||||
| 75 | } | ||||
| 76 | return $string; | ||||
| 77 | } | ||||
| 78 | |||||
| 79 | 1 | 22µs | 1; | ||
| 80 | |||||
| 81 | __END__ |