| Filename | /usr/lib64/perl5/vendor_perl/5.16.0/x86_64-linux/XML/LibXML/Error.pm |
| Statements | Executed 123 statements in 13.7ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 26.5ms | 54.8ms | XML::LibXML::Error::BEGIN@257 |
| 1 | 1 | 1 | 102µs | 203µs | XML::LibXML::Error::BEGIN@11 |
| 1 | 1 | 1 | 95µs | 316µs | XML::LibXML::Error::BEGIN@22 |
| 1 | 1 | 1 | 85µs | 152µs | XML::LibXML::Error::BEGIN@245 |
| 1 | 1 | 1 | 81µs | 255µs | XML::LibXML::Error::BEGIN@67 |
| 1 | 1 | 1 | 70µs | 234µs | XML::LibXML::Error::BEGIN@56 |
| 1 | 1 | 1 | 66µs | 234µs | XML::LibXML::Error::BEGIN@63 |
| 1 | 1 | 1 | 65µs | 256µs | XML::LibXML::Error::BEGIN@47 |
| 1 | 1 | 1 | 63µs | 275µs | XML::LibXML::Error::BEGIN@61 |
| 1 | 1 | 1 | 62µs | 235µs | XML::LibXML::Error::BEGIN@36 |
| 1 | 1 | 1 | 61µs | 233µs | XML::LibXML::Error::BEGIN@37 |
| 1 | 1 | 1 | 61µs | 247µs | XML::LibXML::Error::BEGIN@64 |
| 1 | 1 | 1 | 59µs | 236µs | XML::LibXML::Error::BEGIN@46 |
| 1 | 1 | 1 | 58µs | 225µs | XML::LibXML::Error::BEGIN@42 |
| 1 | 1 | 1 | 55µs | 88µs | XML::LibXML::Error::BEGIN@12 |
| 1 | 1 | 1 | 54µs | 135µs | XML::LibXML::Error::BEGIN@83 |
| 1 | 1 | 1 | 53µs | 290µs | XML::LibXML::Error::BEGIN@20 |
| 1 | 1 | 1 | 53µs | 275µs | XML::LibXML::Error::BEGIN@34 |
| 1 | 1 | 1 | 52µs | 242µs | XML::LibXML::Error::BEGIN@54 |
| 1 | 1 | 1 | 49µs | 262µs | XML::LibXML::Error::BEGIN@57 |
| 1 | 1 | 1 | 49µs | 343µs | XML::LibXML::Error::BEGIN@19 |
| 1 | 1 | 1 | 49µs | 228µs | XML::LibXML::Error::BEGIN@58 |
| 1 | 1 | 1 | 48µs | 240µs | XML::LibXML::Error::BEGIN@52 |
| 1 | 1 | 1 | 48µs | 110µs | XML::LibXML::Error::BEGIN@15 |
| 1 | 1 | 1 | 48µs | 229µs | XML::LibXML::Error::BEGIN@65 |
| 1 | 1 | 1 | 48µs | 225µs | XML::LibXML::Error::BEGIN@62 |
| 1 | 1 | 1 | 47µs | 284µs | XML::LibXML::Error::BEGIN@35 |
| 1 | 1 | 1 | 47µs | 216µs | XML::LibXML::Error::BEGIN@59 |
| 1 | 1 | 1 | 47µs | 221µs | XML::LibXML::Error::BEGIN@48 |
| 1 | 1 | 1 | 47µs | 233µs | XML::LibXML::Error::BEGIN@51 |
| 1 | 1 | 1 | 47µs | 222µs | XML::LibXML::Error::BEGIN@53 |
| 1 | 1 | 1 | 46µs | 237µs | XML::LibXML::Error::BEGIN@66 |
| 1 | 1 | 1 | 46µs | 218µs | XML::LibXML::Error::BEGIN@39 |
| 1 | 1 | 1 | 46µs | 213µs | XML::LibXML::Error::BEGIN@60 |
| 1 | 1 | 1 | 46µs | 219µs | XML::LibXML::Error::BEGIN@45 |
| 1 | 1 | 1 | 46µs | 218µs | XML::LibXML::Error::BEGIN@55 |
| 1 | 1 | 1 | 46µs | 215µs | XML::LibXML::Error::BEGIN@40 |
| 1 | 1 | 1 | 45µs | 213µs | XML::LibXML::Error::BEGIN@43 |
| 1 | 1 | 1 | 45µs | 212µs | XML::LibXML::Error::BEGIN@44 |
| 1 | 1 | 1 | 45µs | 211µs | XML::LibXML::Error::BEGIN@50 |
| 1 | 1 | 1 | 45µs | 213µs | XML::LibXML::Error::BEGIN@49 |
| 1 | 1 | 1 | 44µs | 210µs | XML::LibXML::Error::BEGIN@41 |
| 1 | 1 | 1 | 23µs | 23µ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 | 156µs | 2 | 304µs | # spent 203µs (102+101) within XML::LibXML::Error::BEGIN@11 which was called:
# once (102µs+101µs) by XML::LibXML::BEGIN@24 at line 11 # spent 203µs making 1 call to XML::LibXML::Error::BEGIN@11
# spent 101µs making 1 call to strict::import |
| 12 | 2 | 177µs | 2 | 122µs | # spent 88µs (55+34) within XML::LibXML::Error::BEGIN@12 which was called:
# once (55µs+34µs) by XML::LibXML::BEGIN@24 at line 12 # spent 88µs making 1 call to XML::LibXML::Error::BEGIN@12
# spent 34µs making 1 call to warnings::import |
| 13 | |||||
| 14 | # To avoid a "Deep recursion on subroutine as_string" warning | ||||
| 15 | 2 | 138µs | 2 | 173µs | # spent 110µs (48+62) within XML::LibXML::Error::BEGIN@15 which was called:
# once (48µs+62µs) by XML::LibXML::BEGIN@24 at line 15 # spent 110µs making 1 call to XML::LibXML::Error::BEGIN@15
# spent 62µs making 1 call to warnings::unimport |
| 16 | |||||
| 17 | 2 | 140µs | 1 | 23µs | # spent 23µs within XML::LibXML::Error::BEGIN@17 which was called:
# once (23µs+0s) by XML::LibXML::BEGIN@24 at line 17 # spent 23µs making 1 call to XML::LibXML::Error::BEGIN@17 |
| 18 | |||||
| 19 | 2 | 147µs | 2 | 636µs | # spent 343µs (49+294) within XML::LibXML::Error::BEGIN@19 which was called:
# once (49µs+294µs) by XML::LibXML::BEGIN@24 at line 19 # spent 343µs making 1 call to XML::LibXML::Error::BEGIN@19
# spent 294µs making 1 call to vars::import |
| 20 | 2 | 570µs | 2 | 528µs | # spent 290µs (53+237) within XML::LibXML::Error::BEGIN@20 which was called:
# once (53µs+237µs) by XML::LibXML::BEGIN@24 at line 20 # spent 290µs making 1 call to XML::LibXML::Error::BEGIN@20
# spent 237µs making 1 call to Exporter::import |
| 21 | use overload | ||||
| 22 | # spent 316µs (95+221) within XML::LibXML::Error::BEGIN@22 which was called:
# once (95µs+221µs) by XML::LibXML::BEGIN@24 at line 29 | ||||
| 23 | 'eq' => sub { | ||||
| 24 | ("$_[0]" eq "$_[1]") | ||||
| 25 | }, | ||||
| 26 | 'cmp' => sub { | ||||
| 27 | ("$_[0]" cmp "$_[1]") | ||||
| 28 | }, | ||||
| 29 | 2 | 290µs | 2 | 537µs | fallback => 1; # spent 316µs making 1 call to XML::LibXML::Error::BEGIN@22
# spent 221µs making 1 call to overload::import |
| 30 | |||||
| 31 | 1 | 2µs | $WARNINGS = 0; # 0: supress, 1: report via warn, 2: report via die | ||
| 32 | 1 | 2µs | $VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE | ||
| 33 | |||||
| 34 | 2 | 161µs | 2 | 498µs | # spent 275µs (53+222) within XML::LibXML::Error::BEGIN@34 which was called:
# once (53µs+222µs) by XML::LibXML::BEGIN@24 at line 34 # spent 275µs making 1 call to XML::LibXML::Error::BEGIN@34
# spent 222µs making 1 call to constant::import |
| 35 | 2 | 163µs | 2 | 521µs | # spent 284µs (47+237) within XML::LibXML::Error::BEGIN@35 which was called:
# once (47µs+237µs) by XML::LibXML::BEGIN@24 at line 35 # spent 284µs making 1 call to XML::LibXML::Error::BEGIN@35
# spent 237µs making 1 call to constant::import |
| 36 | 2 | 170µs | 2 | 408µs | # spent 235µs (62+173) within XML::LibXML::Error::BEGIN@36 which was called:
# once (62µs+173µs) by XML::LibXML::BEGIN@24 at line 36 # spent 235µs making 1 call to XML::LibXML::Error::BEGIN@36
# spent 173µs making 1 call to constant::import |
| 37 | 2 | 154µs | 2 | 406µs | # spent 233µs (61+172) within XML::LibXML::Error::BEGIN@37 which was called:
# once (61µs+172µs) by XML::LibXML::BEGIN@24 at line 37 # spent 233µs making 1 call to XML::LibXML::Error::BEGIN@37
# spent 172µs making 1 call to constant::import |
| 38 | |||||
| 39 | 2 | 152µs | 2 | 389µs | # spent 218µs (46+171) within XML::LibXML::Error::BEGIN@39 which was called:
# once (46µs+171µs) by XML::LibXML::BEGIN@24 at line 39 # spent 218µs making 1 call to XML::LibXML::Error::BEGIN@39
# spent 171µs making 1 call to constant::import |
| 40 | 2 | 148µs | 2 | 384µs | # spent 215µs (46+169) within XML::LibXML::Error::BEGIN@40 which was called:
# once (46µs+169µs) by XML::LibXML::BEGIN@24 at line 40 # spent 215µs making 1 call to XML::LibXML::Error::BEGIN@40
# spent 169µs making 1 call to constant::import |
| 41 | 2 | 144µs | 2 | 376µs | # spent 210µs (44+166) within XML::LibXML::Error::BEGIN@41 which was called:
# once (44µs+166µs) by XML::LibXML::BEGIN@24 at line 41 # spent 210µs making 1 call to XML::LibXML::Error::BEGIN@41
# spent 166µs making 1 call to constant::import |
| 42 | 2 | 155µs | 2 | 392µs | # spent 225µs (58+167) within XML::LibXML::Error::BEGIN@42 which was called:
# once (58µs+167µs) by XML::LibXML::BEGIN@24 at line 42 # spent 225µs making 1 call to XML::LibXML::Error::BEGIN@42
# spent 167µs making 1 call to constant::import |
| 43 | 2 | 151µs | 2 | 380µs | # spent 213µs (45+167) within XML::LibXML::Error::BEGIN@43 which was called:
# once (45µs+167µs) by XML::LibXML::BEGIN@24 at line 43 # spent 213µs making 1 call to XML::LibXML::Error::BEGIN@43
# spent 167µs making 1 call to constant::import |
| 44 | 2 | 168µs | 2 | 378µs | # spent 212µs (45+166) within XML::LibXML::Error::BEGIN@44 which was called:
# once (45µs+166µs) by XML::LibXML::BEGIN@24 at line 44 # spent 212µs making 1 call to XML::LibXML::Error::BEGIN@44
# spent 166µs making 1 call to constant::import |
| 45 | 2 | 151µs | 2 | 391µs | # spent 219µs (46+173) within XML::LibXML::Error::BEGIN@45 which was called:
# once (46µs+173µs) by XML::LibXML::BEGIN@24 at line 45 # spent 219µs making 1 call to XML::LibXML::Error::BEGIN@45
# spent 173µs making 1 call to constant::import |
| 46 | 2 | 209µs | 2 | 414µs | # spent 236µs (59+178) within XML::LibXML::Error::BEGIN@46 which was called:
# once (59µs+178µs) by XML::LibXML::BEGIN@24 at line 46 # spent 236µs making 1 call to XML::LibXML::Error::BEGIN@46
# spent 178µs making 1 call to constant::import |
| 47 | 2 | 163µs | 2 | 447µs | # spent 256µs (65+191) within XML::LibXML::Error::BEGIN@47 which was called:
# once (65µs+191µs) by XML::LibXML::BEGIN@24 at line 47 # spent 256µs making 1 call to XML::LibXML::Error::BEGIN@47
# spent 191µs making 1 call to constant::import |
| 48 | 2 | 151µs | 2 | 394µs | # spent 221µs (47+174) within XML::LibXML::Error::BEGIN@48 which was called:
# once (47µs+174µs) by XML::LibXML::BEGIN@24 at line 48 # spent 221µs making 1 call to XML::LibXML::Error::BEGIN@48
# spent 174µs making 1 call to constant::import |
| 49 | 2 | 146µs | 2 | 381µs | # spent 213µs (45+168) within XML::LibXML::Error::BEGIN@49 which was called:
# once (45µs+168µs) by XML::LibXML::BEGIN@24 at line 49 # spent 213µs making 1 call to XML::LibXML::Error::BEGIN@49
# spent 168µs making 1 call to constant::import |
| 50 | 2 | 146µs | 2 | 377µs | # spent 211µs (45+166) within XML::LibXML::Error::BEGIN@50 which was called:
# once (45µs+166µs) by XML::LibXML::BEGIN@24 at line 50 # spent 211µs making 1 call to XML::LibXML::Error::BEGIN@50
# spent 166µs making 1 call to constant::import |
| 51 | 2 | 153µs | 2 | 420µs | # spent 233µs (47+187) within XML::LibXML::Error::BEGIN@51 which was called:
# once (47µs+187µs) by XML::LibXML::BEGIN@24 at line 51 # spent 233µs making 1 call to XML::LibXML::Error::BEGIN@51
# spent 187µs making 1 call to constant::import |
| 52 | 2 | 153µs | 2 | 431µs | # spent 240µs (48+192) within XML::LibXML::Error::BEGIN@52 which was called:
# once (48µs+192µs) by XML::LibXML::BEGIN@24 at line 52 # spent 240µs making 1 call to XML::LibXML::Error::BEGIN@52
# spent 192µs making 1 call to constant::import |
| 53 | 2 | 191µs | 2 | 396µs | # spent 222µs (47+175) within XML::LibXML::Error::BEGIN@53 which was called:
# once (47µs+175µs) by XML::LibXML::BEGIN@24 at line 53 # spent 222µs making 1 call to XML::LibXML::Error::BEGIN@53
# spent 175µs making 1 call to constant::import |
| 54 | 2 | 162µs | 2 | 433µs | # spent 242µs (52+191) within XML::LibXML::Error::BEGIN@54 which was called:
# once (52µs+191µs) by XML::LibXML::BEGIN@24 at line 54 # spent 242µs making 1 call to XML::LibXML::Error::BEGIN@54
# spent 191µs making 1 call to constant::import |
| 55 | 2 | 155µs | 2 | 390µs | # spent 218µs (46+172) within XML::LibXML::Error::BEGIN@55 which was called:
# once (46µs+172µs) by XML::LibXML::BEGIN@24 at line 55 # spent 218µs making 1 call to XML::LibXML::Error::BEGIN@55
# spent 172µs making 1 call to constant::import |
| 56 | 2 | 158µs | 2 | 399µs | # spent 234µs (70+164) within XML::LibXML::Error::BEGIN@56 which was called:
# once (70µs+164µs) by XML::LibXML::BEGIN@24 at line 56 # spent 234µs making 1 call to XML::LibXML::Error::BEGIN@56
# spent 164µs making 1 call to constant::import |
| 57 | 2 | 182µs | 2 | 475µs | # spent 262µs (49+213) within XML::LibXML::Error::BEGIN@57 which was called:
# once (49µs+213µs) by XML::LibXML::BEGIN@24 at line 57 # spent 262µs making 1 call to XML::LibXML::Error::BEGIN@57
# spent 213µs making 1 call to constant::import |
| 58 | 2 | 154µs | 2 | 407µs | # spent 228µs (49+179) within XML::LibXML::Error::BEGIN@58 which was called:
# once (49µs+179µs) by XML::LibXML::BEGIN@24 at line 58 # spent 228µs making 1 call to XML::LibXML::Error::BEGIN@58
# spent 179µs making 1 call to constant::import |
| 59 | 2 | 151µs | 2 | 386µs | # spent 216µs (47+169) within XML::LibXML::Error::BEGIN@59 which was called:
# once (47µs+169µs) by XML::LibXML::BEGIN@24 at line 59 # spent 216µs making 1 call to XML::LibXML::Error::BEGIN@59
# spent 169µs making 1 call to constant::import |
| 60 | 2 | 148µs | 2 | 379µs | # spent 213µs (46+166) within XML::LibXML::Error::BEGIN@60 which was called:
# once (46µs+166µs) by XML::LibXML::BEGIN@24 at line 60 # spent 213µs making 1 call to XML::LibXML::Error::BEGIN@60
# spent 166µs making 1 call to constant::import |
| 61 | 2 | 173µs | 2 | 487µs | # spent 275µs (63+212) within XML::LibXML::Error::BEGIN@61 which was called:
# once (63µs+212µs) by XML::LibXML::BEGIN@24 at line 61 # spent 275µs making 1 call to XML::LibXML::Error::BEGIN@61
# spent 212µs making 1 call to constant::import |
| 62 | 2 | 154µs | 2 | 402µs | # spent 225µs (48+177) within XML::LibXML::Error::BEGIN@62 which was called:
# once (48µs+177µs) by XML::LibXML::BEGIN@24 at line 62 # spent 225µs making 1 call to XML::LibXML::Error::BEGIN@62
# spent 177µs making 1 call to constant::import |
| 63 | 2 | 157µs | 2 | 403µs | # spent 234µs (66+169) within XML::LibXML::Error::BEGIN@63 which was called:
# once (66µs+169µs) by XML::LibXML::BEGIN@24 at line 63 # spent 234µs making 1 call to XML::LibXML::Error::BEGIN@63
# spent 169µs making 1 call to constant::import |
| 64 | 2 | 192µs | 2 | 433µs | # spent 247µs (61+186) within XML::LibXML::Error::BEGIN@64 which was called:
# once (61µs+186µs) by XML::LibXML::BEGIN@24 at line 64 # spent 247µs making 1 call to XML::LibXML::Error::BEGIN@64
# spent 186µs making 1 call to constant::import |
| 65 | 2 | 154µs | 2 | 411µs | # spent 229µs (48+181) within XML::LibXML::Error::BEGIN@65 which was called:
# once (48µs+181µs) by XML::LibXML::BEGIN@24 at line 65 # spent 229µs making 1 call to XML::LibXML::Error::BEGIN@65
# spent 181µs making 1 call to constant::import |
| 66 | 2 | 157µs | 2 | 428µs | # spent 237µs (46+191) within XML::LibXML::Error::BEGIN@66 which was called:
# once (46µs+191µs) by XML::LibXML::BEGIN@24 at line 66 # spent 237µs making 1 call to XML::LibXML::Error::BEGIN@66
# spent 191µs making 1 call to constant::import |
| 67 | 2 | 596µs | 2 | 429µs | # spent 255µs (81+174) within XML::LibXML::Error::BEGIN@67 which was called:
# once (81µs+174µs) by XML::LibXML::BEGIN@24 at line 67 # spent 255µs making 1 call to XML::LibXML::Error::BEGIN@67
# spent 174µs making 1 call to constant::import |
| 68 | |||||
| 69 | 1 | 28µ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 | 2µs | my $MAX_ERROR_PREV_DEPTH = 100; | ||
| 79 | |||||
| 80 | 1 | 6µs | for my $field (qw<code _prev level file line nodename message column context | ||
| 81 | str1 str2 str3 num1 num2 __prev_depth>) { | ||||
| 82 | 15 | 136µs | my $method = sub { $_[0]{$field} }; | ||
| 83 | 2 | 4.27ms | 2 | 215µs | # spent 135µs (54+80) within XML::LibXML::Error::BEGIN@83 which was called:
# once (54µs+80µs) by XML::LibXML::BEGIN@24 at line 83 # spent 135µs making 1 call to XML::LibXML::Error::BEGIN@83
# spent 80µs making 1 call to strict::unimport |
| 84 | 15 | 191µs | *$field = $method; | ||
| 85 | } | ||||
| 86 | |||||
| 87 | { | ||||
| 88 | |||||
| 89 | 1 | 2µs | 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 | 745µs | 2 | 220µs | # spent 152µs (85+68) within XML::LibXML::Error::BEGIN@245 which was called:
# once (85µs+68µs) by XML::LibXML::BEGIN@24 at line 245 # spent 152µs making 1 call to XML::LibXML::Error::BEGIN@245
# spent 68µ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 | 987µs | 2 | 55.0ms | # spent 54.8ms (26.5+28.2) within XML::LibXML::Error::BEGIN@257 which was called:
# once (26.5ms+28.2ms) by XML::LibXML::BEGIN@24 at line 257 # spent 54.8ms making 1 call to XML::LibXML::Error::BEGIN@257
# spent 230µs making 1 call to Exporter::import |
| 258 | return Data::Dumper->new([$self],['error'])->Dump; | ||||
| 259 | } | ||||
| 260 | |||||
| 261 | 1 | 36µs | 1; |