| Filename | /usr/lib/x86_64-linux-gnu/perl5/5.20/XML/LibXML/Error.pm |
| Statements | Executed 123 statements in 2.70ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 4.54ms | 4.86ms | XML::LibXML::Error::BEGIN@257 |
| 1 | 1 | 1 | 14µs | 24µs | XML::LibXML::Error::BEGIN@11 |
| 1 | 1 | 1 | 10µs | 47µs | XML::LibXML::Error::BEGIN@22 |
| 1 | 1 | 1 | 9µs | 18µs | XML::LibXML::Error::BEGIN@83 |
| 1 | 1 | 1 | 9µs | 20µs | XML::LibXML::Error::BEGIN@245 |
| 1 | 1 | 1 | 9µs | 34µs | XML::LibXML::Error::BEGIN@47 |
| 1 | 1 | 1 | 7µs | 11µs | XML::LibXML::Error::BEGIN@12 |
| 1 | 1 | 1 | 6µs | 20µs | XML::LibXML::Error::BEGIN@15 |
| 1 | 1 | 1 | 6µs | 32µs | XML::LibXML::Error::BEGIN@20 |
| 1 | 1 | 1 | 6µs | 30µs | XML::LibXML::Error::BEGIN@34 |
| 1 | 1 | 1 | 6µs | 35µs | XML::LibXML::Error::BEGIN@19 |
| 1 | 1 | 1 | 6µs | 24µs | XML::LibXML::Error::BEGIN@62 |
| 1 | 1 | 1 | 6µs | 24µs | XML::LibXML::Error::BEGIN@42 |
| 1 | 1 | 1 | 6µs | 23µs | XML::LibXML::Error::BEGIN@54 |
| 1 | 1 | 1 | 6µs | 27µs | XML::LibXML::Error::BEGIN@58 |
| 1 | 1 | 1 | 6µs | 23µs | XML::LibXML::Error::BEGIN@66 |
| 1 | 1 | 1 | 6µs | 23µs | XML::LibXML::Error::BEGIN@44 |
| 1 | 1 | 1 | 6µs | 24µs | XML::LibXML::Error::BEGIN@51 |
| 1 | 1 | 1 | 5µs | 25µs | XML::LibXML::Error::BEGIN@37 |
| 1 | 1 | 1 | 5µs | 24µs | XML::LibXML::Error::BEGIN@39 |
| 1 | 1 | 1 | 5µs | 25µs | XML::LibXML::Error::BEGIN@41 |
| 1 | 1 | 1 | 5µs | 24µs | XML::LibXML::Error::BEGIN@63 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@67 |
| 1 | 1 | 1 | 5µs | 24µs | XML::LibXML::Error::BEGIN@40 |
| 1 | 1 | 1 | 5µs | 22µs | XML::LibXML::Error::BEGIN@60 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@64 |
| 1 | 1 | 1 | 5µs | 24µs | XML::LibXML::Error::BEGIN@65 |
| 1 | 1 | 1 | 5µs | 25µs | XML::LibXML::Error::BEGIN@35 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@43 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@46 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@50 |
| 1 | 1 | 1 | 5µs | 24µs | XML::LibXML::Error::BEGIN@52 |
| 1 | 1 | 1 | 5µs | 26µs | XML::LibXML::Error::BEGIN@59 |
| 1 | 1 | 1 | 5µs | 24µs | XML::LibXML::Error::BEGIN@36 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@48 |
| 1 | 1 | 1 | 5µs | 27µs | XML::LibXML::Error::BEGIN@49 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@55 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@57 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@61 |
| 1 | 1 | 1 | 5µs | 26µs | XML::LibXML::Error::BEGIN@45 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@53 |
| 1 | 1 | 1 | 5µs | 23µs | XML::LibXML::Error::BEGIN@56 |
| 1 | 1 | 1 | 3µs | 3µs | XML::LibXML::Error::BEGIN@17 |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::__ANON__[:25] |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::__ANON__[:28] |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::__ANON__[:82] |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::_callback_error |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::_instant_error_callback |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::_report_error |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::_report_warning |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::as_string |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::domain |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::dump |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::int1 |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::int2 |
| 0 | 0 | 0 | 0s | 0s | XML::LibXML::Error::new |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | # $Id: Error.pm,v 1.1.2.1 2004/04/20 20:09:48 pajas Exp $ | ||||
| 2 | # | ||||
| 3 | # This is free software, you may use it and distribute it under the same terms as | ||||
| 4 | # Perl itself. | ||||
| 5 | # | ||||
| 6 | # Copyright 2001-2003 AxKit.com Ltd., 2002-2006 Christian Glahn, 2006-2009 Petr Pajas | ||||
| 7 | # | ||||
| 8 | # | ||||
| 9 | package XML::LibXML::Error; | ||||
| 10 | |||||
| 11 | 2 | 25µs | 2 | 34µs | # spent 24µs (14+10) within XML::LibXML::Error::BEGIN@11 which was called:
# once (14µs+10µs) by XML::LibXML::BEGIN@26 at line 11 # spent 24µs making 1 call to XML::LibXML::Error::BEGIN@11
# spent 10µs making 1 call to strict::import |
| 12 | 2 | 22µs | 2 | 15µs | # spent 11µs (7+4) within XML::LibXML::Error::BEGIN@12 which was called:
# once (7µs+4µs) by XML::LibXML::BEGIN@26 at line 12 # spent 11µs making 1 call to XML::LibXML::Error::BEGIN@12
# spent 4µs making 1 call to warnings::import |
| 13 | |||||
| 14 | # To avoid a "Deep recursion on subroutine as_string" warning | ||||
| 15 | 2 | 20µs | 2 | 34µs | # spent 20µs (6+14) within XML::LibXML::Error::BEGIN@15 which was called:
# once (6µs+14µs) by XML::LibXML::BEGIN@26 at line 15 # spent 20µs making 1 call to XML::LibXML::Error::BEGIN@15
# spent 14µs making 1 call to warnings::unimport |
| 16 | |||||
| 17 | 2 | 21µs | 1 | 3µs | # spent 3µs within XML::LibXML::Error::BEGIN@17 which was called:
# once (3µs+0s) by XML::LibXML::BEGIN@26 at line 17 # spent 3µs making 1 call to XML::LibXML::Error::BEGIN@17 |
| 18 | |||||
| 19 | 2 | 19µs | 2 | 64µs | # spent 35µs (6+29) within XML::LibXML::Error::BEGIN@19 which was called:
# once (6µs+29µs) by XML::LibXML::BEGIN@26 at line 19 # spent 35µs making 1 call to XML::LibXML::Error::BEGIN@19
# spent 29µs making 1 call to vars::import |
| 20 | 2 | 93µs | 2 | 57µs | # spent 32µs (6+25) within XML::LibXML::Error::BEGIN@20 which was called:
# once (6µs+25µs) by XML::LibXML::BEGIN@26 at line 20 # spent 32µs making 1 call to XML::LibXML::Error::BEGIN@20
# spent 25µs making 1 call to Exporter::import |
| 21 | use overload | ||||
| 22 | # spent 47µs (10+36) within XML::LibXML::Error::BEGIN@22 which was called:
# once (10µs+36µs) by XML::LibXML::BEGIN@26 at line 29 | ||||
| 23 | 'eq' => sub { | ||||
| 24 | ("$_[0]" eq "$_[1]") | ||||
| 25 | }, | ||||
| 26 | 'cmp' => sub { | ||||
| 27 | ("$_[0]" cmp "$_[1]") | ||||
| 28 | }, | ||||
| 29 | 2 | 38µs | 2 | 83µs | fallback => 1; # spent 47µs making 1 call to XML::LibXML::Error::BEGIN@22
# spent 36µs making 1 call to overload::import |
| 30 | |||||
| 31 | 1 | 300ns | $WARNINGS = 0; # 0: suppress, 1: report via warn, 2: report via die | ||
| 32 | 1 | 200ns | $VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE | ||
| 33 | |||||
| 34 | 2 | 22µs | 2 | 54µs | # spent 30µs (6+24) within XML::LibXML::Error::BEGIN@34 which was called:
# once (6µs+24µs) by XML::LibXML::BEGIN@26 at line 34 # spent 30µs making 1 call to XML::LibXML::Error::BEGIN@34
# spent 24µs making 1 call to constant::import |
| 35 | 2 | 20µs | 2 | 44µs | # spent 25µs (5+20) within XML::LibXML::Error::BEGIN@35 which was called:
# once (5µs+20µs) by XML::LibXML::BEGIN@26 at line 35 # spent 25µs making 1 call to XML::LibXML::Error::BEGIN@35
# spent 20µs making 1 call to constant::import |
| 36 | 2 | 24µs | 2 | 42µs | # spent 24µs (5+19) within XML::LibXML::Error::BEGIN@36 which was called:
# once (5µs+19µs) by XML::LibXML::BEGIN@26 at line 36 # spent 24µs making 1 call to XML::LibXML::Error::BEGIN@36
# spent 19µs making 1 call to constant::import |
| 37 | 2 | 25µs | 2 | 44µs | # spent 25µs (5+19) within XML::LibXML::Error::BEGIN@37 which was called:
# once (5µs+19µs) by XML::LibXML::BEGIN@26 at line 37 # spent 25µs making 1 call to XML::LibXML::Error::BEGIN@37
# spent 19µs making 1 call to constant::import |
| 38 | |||||
| 39 | 2 | 21µs | 2 | 43µs | # spent 24µs (5+19) within XML::LibXML::Error::BEGIN@39 which was called:
# once (5µs+19µs) by XML::LibXML::BEGIN@26 at line 39 # spent 24µs making 1 call to XML::LibXML::Error::BEGIN@39
# spent 19µs making 1 call to constant::import |
| 40 | 2 | 25µs | 2 | 42µs | # spent 24µs (5+18) within XML::LibXML::Error::BEGIN@40 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 40 # spent 24µs making 1 call to XML::LibXML::Error::BEGIN@40
# spent 18µs making 1 call to constant::import |
| 41 | 2 | 20µs | 2 | 44µs | # spent 25µs (5+19) within XML::LibXML::Error::BEGIN@41 which was called:
# once (5µs+19µs) by XML::LibXML::BEGIN@26 at line 41 # spent 25µs making 1 call to XML::LibXML::Error::BEGIN@41
# spent 19µs making 1 call to constant::import |
| 42 | 2 | 22µs | 2 | 43µs | # spent 24µs (6+19) within XML::LibXML::Error::BEGIN@42 which was called:
# once (6µs+19µs) by XML::LibXML::BEGIN@26 at line 42 # spent 24µs making 1 call to XML::LibXML::Error::BEGIN@42
# spent 19µs making 1 call to constant::import |
| 43 | 2 | 23µs | 2 | 42µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@43 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 43 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@43
# spent 18µs making 1 call to constant::import |
| 44 | 2 | 20µs | 2 | 41µs | # spent 23µs (6+18) within XML::LibXML::Error::BEGIN@44 which was called:
# once (6µs+18µs) by XML::LibXML::BEGIN@26 at line 44 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@44
# spent 18µs making 1 call to constant::import |
| 45 | 2 | 20µs | 2 | 48µs | # spent 26µs (5+22) within XML::LibXML::Error::BEGIN@45 which was called:
# once (5µs+22µs) by XML::LibXML::BEGIN@26 at line 45 # spent 26µs making 1 call to XML::LibXML::Error::BEGIN@45
# spent 22µs making 1 call to constant::import |
| 46 | 2 | 19µs | 2 | 40µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@46 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 46 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@46
# spent 18µs making 1 call to constant::import |
| 47 | 2 | 20µs | 2 | 59µs | # spent 34µs (9+25) within XML::LibXML::Error::BEGIN@47 which was called:
# once (9µs+25µs) by XML::LibXML::BEGIN@26 at line 47 # spent 34µs making 1 call to XML::LibXML::Error::BEGIN@47
# spent 25µs making 1 call to constant::import |
| 48 | 2 | 20µs | 2 | 42µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@48 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 48 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@48
# spent 18µs making 1 call to constant::import |
| 49 | 2 | 20µs | 2 | 48µs | # spent 27µs (5+22) within XML::LibXML::Error::BEGIN@49 which was called:
# once (5µs+22µs) by XML::LibXML::BEGIN@26 at line 49 # spent 27µs making 1 call to XML::LibXML::Error::BEGIN@49
# spent 22µs making 1 call to constant::import |
| 50 | 2 | 20µs | 2 | 40µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@50 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 50 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@50
# spent 18µs making 1 call to constant::import |
| 51 | 2 | 23µs | 2 | 43µs | # spent 24µs (6+19) within XML::LibXML::Error::BEGIN@51 which was called:
# once (6µs+19µs) by XML::LibXML::BEGIN@26 at line 51 # spent 24µs making 1 call to XML::LibXML::Error::BEGIN@51
# spent 19µs making 1 call to constant::import |
| 52 | 2 | 23µs | 2 | 43µs | # spent 24µs (5+19) within XML::LibXML::Error::BEGIN@52 which was called:
# once (5µs+19µs) by XML::LibXML::BEGIN@26 at line 52 # spent 24µs making 1 call to XML::LibXML::Error::BEGIN@52
# spent 19µs making 1 call to constant::import |
| 53 | 2 | 20µs | 2 | 41µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@53 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 53 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@53
# spent 18µs making 1 call to constant::import |
| 54 | 2 | 20µs | 2 | 41µs | # spent 23µs (6+18) within XML::LibXML::Error::BEGIN@54 which was called:
# once (6µs+18µs) by XML::LibXML::BEGIN@26 at line 54 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@54
# spent 18µs making 1 call to constant::import |
| 55 | 2 | 19µs | 2 | 41µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@55 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 55 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@55
# spent 18µs making 1 call to constant::import |
| 56 | 2 | 24µs | 2 | 41µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@56 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 56 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@56
# spent 18µs making 1 call to constant::import |
| 57 | 2 | 24µs | 2 | 41µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@57 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 57 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@57
# spent 18µs making 1 call to constant::import |
| 58 | 2 | 20µs | 2 | 48µs | # spent 27µs (6+21) within XML::LibXML::Error::BEGIN@58 which was called:
# once (6µs+21µs) by XML::LibXML::BEGIN@26 at line 58 # spent 27µs making 1 call to XML::LibXML::Error::BEGIN@58
# spent 21µs making 1 call to constant::import |
| 59 | 2 | 20µs | 2 | 47µs | # spent 26µs (5+21) within XML::LibXML::Error::BEGIN@59 which was called:
# once (5µs+21µs) by XML::LibXML::BEGIN@26 at line 59 # spent 26µs making 1 call to XML::LibXML::Error::BEGIN@59
# spent 21µs making 1 call to constant::import |
| 60 | 2 | 19µs | 2 | 39µs | # spent 22µs (5+17) within XML::LibXML::Error::BEGIN@60 which was called:
# once (5µs+17µs) by XML::LibXML::BEGIN@26 at line 60 # spent 22µs making 1 call to XML::LibXML::Error::BEGIN@60
# spent 17µs making 1 call to constant::import |
| 61 | 2 | 23µs | 2 | 41µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@61 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 61 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@61
# spent 18µs making 1 call to constant::import |
| 62 | 2 | 20µs | 2 | 42µs | # spent 24µs (6+18) within XML::LibXML::Error::BEGIN@62 which was called:
# once (6µs+18µs) by XML::LibXML::BEGIN@26 at line 62 # spent 24µs making 1 call to XML::LibXML::Error::BEGIN@62
# spent 18µs making 1 call to constant::import |
| 63 | 2 | 20µs | 2 | 43µs | # spent 24µs (5+19) within XML::LibXML::Error::BEGIN@63 which was called:
# once (5µs+19µs) by XML::LibXML::BEGIN@26 at line 63 # spent 24µs making 1 call to XML::LibXML::Error::BEGIN@63
# spent 19µs making 1 call to constant::import |
| 64 | 2 | 23µs | 2 | 41µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@64 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 64 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@64
# spent 18µs making 1 call to constant::import |
| 65 | 2 | 20µs | 2 | 42µs | # spent 24µs (5+19) within XML::LibXML::Error::BEGIN@65 which was called:
# once (5µs+19µs) by XML::LibXML::BEGIN@26 at line 65 # spent 24µs making 1 call to XML::LibXML::Error::BEGIN@65
# spent 18µs making 1 call to constant::import |
| 66 | 2 | 24µs | 2 | 41µs | # spent 23µs (6+18) within XML::LibXML::Error::BEGIN@66 which was called:
# once (6µs+18µs) by XML::LibXML::BEGIN@26 at line 66 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@66
# spent 18µs making 1 call to constant::import |
| 67 | 2 | 83µs | 2 | 41µs | # spent 23µs (5+18) within XML::LibXML::Error::BEGIN@67 which was called:
# once (5µs+18µs) by XML::LibXML::BEGIN@26 at line 67 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@67
# spent 18µs making 1 call to constant::import |
| 68 | |||||
| 69 | 1 | 2µs | @error_domains = ("", "parser", "tree", "namespace", "validity", | ||
| 70 | "HTML parser", "memory", "output", "I/O", "ftp", | ||||
| 71 | "http", "XInclude", "XPath", "xpointer", "regexp", | ||||
| 72 | "Schemas datatype", "Schemas parser", "Schemas validity", | ||||
| 73 | "Relax-NG parser", "Relax-NG validity", | ||||
| 74 | "Catalog", "C14N", "XSLT", "validity", "error-checking", | ||||
| 75 | "xmlwriter", "dynamic loading", "i18n", | ||||
| 76 | "Schematron validity"); | ||||
| 77 | |||||
| 78 | 1 | 100ns | my $MAX_ERROR_PREV_DEPTH = 100; | ||
| 79 | |||||
| 80 | 1 | 700ns | for my $field (qw<code _prev level file line nodename message column context | ||
| 81 | str1 str2 str3 num1 num2 __prev_depth>) { | ||||
| 82 | 15 | 12µs | my $method = sub { $_[0]{$field} }; | ||
| 83 | 2 | 808µs | 2 | 27µs | # spent 18µs (9+9) within XML::LibXML::Error::BEGIN@83 which was called:
# once (9µs+9µs) by XML::LibXML::BEGIN@26 at line 83 # spent 18µs making 1 call to XML::LibXML::Error::BEGIN@83
# spent 9µs making 1 call to strict::unimport |
| 84 | 15 | 16µs | *$field = $method; | ||
| 85 | } | ||||
| 86 | |||||
| 87 | { | ||||
| 88 | |||||
| 89 | 1 | 200ns | sub new { | ||
| 90 | my ($class,$xE) = @_; | ||||
| 91 | my $terr; | ||||
| 92 | if (ref($xE)) { | ||||
| 93 | my ($context,$column) = $xE->context_and_column(); | ||||
| 94 | $terr =bless { | ||||
| 95 | domain => $xE->domain(), | ||||
| 96 | level => $xE->level(), | ||||
| 97 | code => $xE->code(), | ||||
| 98 | message => $xE->message(), | ||||
| 99 | file => $xE->file(), | ||||
| 100 | line => $xE->line(), | ||||
| 101 | str1 => $xE->str1(), | ||||
| 102 | str2 => $xE->str2(), | ||||
| 103 | str3 => $xE->str3(), | ||||
| 104 | num1 => $xE->num1(), | ||||
| 105 | num2 => $xE->num2(), | ||||
| 106 | __prev_depth => 0, | ||||
| 107 | (defined($context) ? | ||||
| 108 | ( | ||||
| 109 | context => $context, | ||||
| 110 | column => $column, | ||||
| 111 | ) : ()), | ||||
| 112 | }, $class; | ||||
| 113 | } else { | ||||
| 114 | # !!!! problem : got a flat error | ||||
| 115 | # warn("PROBLEM: GOT A FLAT ERROR $xE\n"); | ||||
| 116 | $terr =bless { | ||||
| 117 | domain => 0, | ||||
| 118 | level => 2, | ||||
| 119 | code => -1, | ||||
| 120 | message => $xE, | ||||
| 121 | file => undef, | ||||
| 122 | line => undef, | ||||
| 123 | str1 => undef, | ||||
| 124 | str2 => undef, | ||||
| 125 | str3 => undef, | ||||
| 126 | num1 => undef, | ||||
| 127 | num2 => undef, | ||||
| 128 | __prev_depth => 0, | ||||
| 129 | }, $class; | ||||
| 130 | } | ||||
| 131 | return $terr; | ||||
| 132 | } | ||||
| 133 | |||||
| 134 | sub _callback_error { | ||||
| 135 | #print "CALLBACK\n"; | ||||
| 136 | my ($xE,$prev) = @_; | ||||
| 137 | my $terr; | ||||
| 138 | $terr=XML::LibXML::Error->new($xE); | ||||
| 139 | if ($terr->{level} == XML_ERR_WARNING and $WARNINGS!=2) { | ||||
| 140 | warn $terr if $WARNINGS; | ||||
| 141 | return $prev; | ||||
| 142 | } | ||||
| 143 | #unless ( defined $terr->{file} and length $terr->{file} ) { | ||||
| 144 | # this would make it easier to recognize parsed strings | ||||
| 145 | # but it breaks old implementations | ||||
| 146 | # [CG] $terr->{file} = 'string()'; | ||||
| 147 | #} | ||||
| 148 | #warn "Saving the error ",$terr->dump; | ||||
| 149 | |||||
| 150 | if (ref($prev)) | ||||
| 151 | { | ||||
| 152 | if ($prev->__prev_depth() >= $MAX_ERROR_PREV_DEPTH) | ||||
| 153 | { | ||||
| 154 | return $prev; | ||||
| 155 | } | ||||
| 156 | $terr->{_prev} = $prev; | ||||
| 157 | $terr->{__prev_depth} = $prev->__prev_depth() + 1; | ||||
| 158 | } | ||||
| 159 | else | ||||
| 160 | { | ||||
| 161 | $terr->{_prev} = defined($prev) && length($prev) ? XML::LibXML::Error->new($prev) : undef; | ||||
| 162 | } | ||||
| 163 | return $terr; | ||||
| 164 | } | ||||
| 165 | sub _instant_error_callback { | ||||
| 166 | my $xE = shift; | ||||
| 167 | my $terr= XML::LibXML::Error->new($xE); | ||||
| 168 | print "Reporting an instanteous error ",$terr->dump; | ||||
| 169 | die $terr; | ||||
| 170 | } | ||||
| 171 | sub _report_warning { | ||||
| 172 | my ($saved_error) = @_; | ||||
| 173 | #print "CALLBACK WARN\n"; | ||||
| 174 | if ( defined $saved_error ) { | ||||
| 175 | #print "reporting a warning ",$saved_error->dump; | ||||
| 176 | warn $saved_error; | ||||
| 177 | } | ||||
| 178 | } | ||||
| 179 | sub _report_error { | ||||
| 180 | my ($saved_error) = @_; | ||||
| 181 | #print "CALLBACK ERROR: $saved_error\n"; | ||||
| 182 | if ( defined $saved_error ) { | ||||
| 183 | die $saved_error; | ||||
| 184 | } | ||||
| 185 | } | ||||
| 186 | } | ||||
| 187 | |||||
| 188 | |||||
| 189 | # backward compatibility | ||||
| 190 | sub int1 { $_[0]->num1 } | ||||
| 191 | sub int2 { $_[0]->num2 } | ||||
| 192 | |||||
| 193 | sub domain { | ||||
| 194 | my ($self)=@_; | ||||
| 195 | return undef unless ref($self); | ||||
| 196 | my $domain = $self->{domain}; | ||||
| 197 | # Newer versions of libxml2 might yield errors in domains that aren't | ||||
| 198 | # listed above. Invent something reasonable in that case. | ||||
| 199 | return $domain < @error_domains ? $error_domains[$domain] : "domain_$domain"; | ||||
| 200 | } | ||||
| 201 | |||||
| 202 | sub as_string { | ||||
| 203 | my ($self)=@_; | ||||
| 204 | my $msg = ""; | ||||
| 205 | my $level; | ||||
| 206 | |||||
| 207 | if (defined($self->{_prev})) { | ||||
| 208 | $msg = $self->{_prev}->as_string; | ||||
| 209 | } | ||||
| 210 | |||||
| 211 | if ($self->{level} == XML_ERR_NONE) { | ||||
| 212 | $level = ""; | ||||
| 213 | } elsif ($self->{level} == XML_ERR_WARNING) { | ||||
| 214 | $level = "warning"; | ||||
| 215 | } elsif ($self->{level} == XML_ERR_ERROR || | ||||
| 216 | $self->{level} == XML_ERR_FATAL) { | ||||
| 217 | $level = "error"; | ||||
| 218 | } | ||||
| 219 | my $where=""; | ||||
| 220 | if (defined($self->{file})) { | ||||
| 221 | $where="$self->{file}:$self->{line}"; | ||||
| 222 | } elsif (($self->{domain} == XML_ERR_FROM_PARSER) | ||||
| 223 | and | ||||
| 224 | $self->{line}) { | ||||
| 225 | $where="Entity: line $self->{line}"; | ||||
| 226 | } | ||||
| 227 | if ($self->{nodename}) { | ||||
| 228 | $where.=": element ".$self->{nodename}; | ||||
| 229 | } | ||||
| 230 | $msg.=$where.": " if $where ne ""; | ||||
| 231 | $msg.=$self->domain." ".$level." :"; | ||||
| 232 | my $str=$self->{message}||""; | ||||
| 233 | chomp($str); | ||||
| 234 | $msg.=" ".$str."\n"; | ||||
| 235 | if (($self->{domain} == XML_ERR_FROM_XPATH) and | ||||
| 236 | defined($self->{str1})) { | ||||
| 237 | $msg.=$self->{str1}."\n"; | ||||
| 238 | $msg.=(" " x $self->{num1})."^\n"; | ||||
| 239 | } elsif (defined $self->{context}) { | ||||
| 240 | # If the error relates to character-encoding problems in the context, | ||||
| 241 | # then doing textual operations on it will spew warnings that | ||||
| 242 | # XML::LibXML can do nothing to fix. So just disable all such | ||||
| 243 | # warnings. This has the pleasing benefit of making the test suite | ||||
| 244 | # run warning-free. | ||||
| 245 | 2 | 119µs | 2 | 32µs | # spent 20µs (9+11) within XML::LibXML::Error::BEGIN@245 which was called:
# once (9µs+11µs) by XML::LibXML::BEGIN@26 at line 245 # spent 20µs making 1 call to XML::LibXML::Error::BEGIN@245
# spent 11µs making 1 call to warnings::unimport |
| 246 | my $context = Encode::encode('utf8', $self->{context}, Encode::FB_DEFAULT); | ||||
| 247 | $msg.=$context."\n"; | ||||
| 248 | $context = substr($context,0,$self->{column}); | ||||
| 249 | $context=~s/[^\t]/ /g; | ||||
| 250 | $msg.=$context."^\n"; | ||||
| 251 | } | ||||
| 252 | return $msg; | ||||
| 253 | } | ||||
| 254 | |||||
| 255 | sub dump { | ||||
| 256 | my ($self)=@_; | ||||
| 257 | 2 | 731µs | 2 | 4.88ms | # spent 4.86ms (4.54+317µs) within XML::LibXML::Error::BEGIN@257 which was called:
# once (4.54ms+317µs) by XML::LibXML::BEGIN@26 at line 257 # spent 4.86ms making 1 call to XML::LibXML::Error::BEGIN@257
# spent 23µs making 1 call to Exporter::import |
| 258 | return Data::Dumper->new([$self],['error'])->Dump; | ||||
| 259 | } | ||||
| 260 | |||||
| 261 | 1 | 5µs | 1; |