← Index
NYTProf Performance Profile   « line view »
For svc/members/upsert
  Run on Tue Jan 13 11:50:22 2015
Reported on Tue Jan 13 12:09:49 2015

Filename/usr/lib/x86_64-linux-gnu/perl5/5.20/XML/LibXML/Error.pm
StatementsExecuted 123 statements in 2.70ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
1114.54ms4.86msXML::LibXML::Error::::BEGIN@257XML::LibXML::Error::BEGIN@257
11114µs24µsXML::LibXML::Error::::BEGIN@11XML::LibXML::Error::BEGIN@11
11110µs47µsXML::LibXML::Error::::BEGIN@22XML::LibXML::Error::BEGIN@22
1119µs18µsXML::LibXML::Error::::BEGIN@83XML::LibXML::Error::BEGIN@83
1119µs20µsXML::LibXML::Error::::BEGIN@245XML::LibXML::Error::BEGIN@245
1119µs34µsXML::LibXML::Error::::BEGIN@47XML::LibXML::Error::BEGIN@47
1117µs11µsXML::LibXML::Error::::BEGIN@12XML::LibXML::Error::BEGIN@12
1116µs20µsXML::LibXML::Error::::BEGIN@15XML::LibXML::Error::BEGIN@15
1116µs32µsXML::LibXML::Error::::BEGIN@20XML::LibXML::Error::BEGIN@20
1116µs30µsXML::LibXML::Error::::BEGIN@34XML::LibXML::Error::BEGIN@34
1116µs35µsXML::LibXML::Error::::BEGIN@19XML::LibXML::Error::BEGIN@19
1116µs24µsXML::LibXML::Error::::BEGIN@62XML::LibXML::Error::BEGIN@62
1116µs24µsXML::LibXML::Error::::BEGIN@42XML::LibXML::Error::BEGIN@42
1116µs23µsXML::LibXML::Error::::BEGIN@54XML::LibXML::Error::BEGIN@54
1116µs27µsXML::LibXML::Error::::BEGIN@58XML::LibXML::Error::BEGIN@58
1116µs23µsXML::LibXML::Error::::BEGIN@66XML::LibXML::Error::BEGIN@66
1116µs23µsXML::LibXML::Error::::BEGIN@44XML::LibXML::Error::BEGIN@44
1116µs24µsXML::LibXML::Error::::BEGIN@51XML::LibXML::Error::BEGIN@51
1115µs25µsXML::LibXML::Error::::BEGIN@37XML::LibXML::Error::BEGIN@37
1115µs24µsXML::LibXML::Error::::BEGIN@39XML::LibXML::Error::BEGIN@39
1115µs25µsXML::LibXML::Error::::BEGIN@41XML::LibXML::Error::BEGIN@41
1115µs24µsXML::LibXML::Error::::BEGIN@63XML::LibXML::Error::BEGIN@63
1115µs23µsXML::LibXML::Error::::BEGIN@67XML::LibXML::Error::BEGIN@67
1115µs24µsXML::LibXML::Error::::BEGIN@40XML::LibXML::Error::BEGIN@40
1115µs22µsXML::LibXML::Error::::BEGIN@60XML::LibXML::Error::BEGIN@60
1115µs23µsXML::LibXML::Error::::BEGIN@64XML::LibXML::Error::BEGIN@64
1115µs24µsXML::LibXML::Error::::BEGIN@65XML::LibXML::Error::BEGIN@65
1115µs25µsXML::LibXML::Error::::BEGIN@35XML::LibXML::Error::BEGIN@35
1115µs23µsXML::LibXML::Error::::BEGIN@43XML::LibXML::Error::BEGIN@43
1115µs23µsXML::LibXML::Error::::BEGIN@46XML::LibXML::Error::BEGIN@46
1115µs23µsXML::LibXML::Error::::BEGIN@50XML::LibXML::Error::BEGIN@50
1115µs24µsXML::LibXML::Error::::BEGIN@52XML::LibXML::Error::BEGIN@52
1115µs26µsXML::LibXML::Error::::BEGIN@59XML::LibXML::Error::BEGIN@59
1115µs24µsXML::LibXML::Error::::BEGIN@36XML::LibXML::Error::BEGIN@36
1115µs23µsXML::LibXML::Error::::BEGIN@48XML::LibXML::Error::BEGIN@48
1115µs27µsXML::LibXML::Error::::BEGIN@49XML::LibXML::Error::BEGIN@49
1115µs23µsXML::LibXML::Error::::BEGIN@55XML::LibXML::Error::BEGIN@55
1115µs23µsXML::LibXML::Error::::BEGIN@57XML::LibXML::Error::BEGIN@57
1115µs23µsXML::LibXML::Error::::BEGIN@61XML::LibXML::Error::BEGIN@61
1115µs26µsXML::LibXML::Error::::BEGIN@45XML::LibXML::Error::BEGIN@45
1115µs23µsXML::LibXML::Error::::BEGIN@53XML::LibXML::Error::BEGIN@53
1115µs23µsXML::LibXML::Error::::BEGIN@56XML::LibXML::Error::BEGIN@56
1113µs3µsXML::LibXML::Error::::BEGIN@17XML::LibXML::Error::BEGIN@17
0000s0sXML::LibXML::Error::::__ANON__[:25]XML::LibXML::Error::__ANON__[:25]
0000s0sXML::LibXML::Error::::__ANON__[:28]XML::LibXML::Error::__ANON__[:28]
0000s0sXML::LibXML::Error::::__ANON__[:82]XML::LibXML::Error::__ANON__[:82]
0000s0sXML::LibXML::Error::::_callback_errorXML::LibXML::Error::_callback_error
0000s0sXML::LibXML::Error::::_instant_error_callbackXML::LibXML::Error::_instant_error_callback
0000s0sXML::LibXML::Error::::_report_errorXML::LibXML::Error::_report_error
0000s0sXML::LibXML::Error::::_report_warningXML::LibXML::Error::_report_warning
0000s0sXML::LibXML::Error::::as_stringXML::LibXML::Error::as_string
0000s0sXML::LibXML::Error::::domainXML::LibXML::Error::domain
0000s0sXML::LibXML::Error::::dumpXML::LibXML::Error::dump
0000s0sXML::LibXML::Error::::int1XML::LibXML::Error::int1
0000s0sXML::LibXML::Error::::int2XML::LibXML::Error::int2
0000s0sXML::LibXML::Error::::newXML::LibXML::Error::new
Call graph for these subroutines as a Graphviz dot language file.
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#
9package XML::LibXML::Error;
10
11225µs234µ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
use strict;
# spent 24µs making 1 call to XML::LibXML::Error::BEGIN@11 # spent 10µs making 1 call to strict::import
12222µs215µ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
use warnings;
# 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
15220µs234µ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
no warnings 'recursion';
# spent 20µs making 1 call to XML::LibXML::Error::BEGIN@15 # spent 14µs making 1 call to warnings::unimport
16
17221µs13µ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
use Encode ();
# spent 3µs making 1 call to XML::LibXML::Error::BEGIN@17
18
19219µs264µ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
use vars qw(@error_domains $VERSION $WARNINGS);
# spent 35µs making 1 call to XML::LibXML::Error::BEGIN@19 # spent 29µs making 1 call to vars::import
20293µs257µ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
use Carp;
# spent 32µs making 1 call to XML::LibXML::Error::BEGIN@20 # spent 25µs making 1 call to Exporter::import
21use 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
'""' => \&as_string,
23 'eq' => sub {
24 ("$_[0]" eq "$_[1]")
25 },
26 'cmp' => sub {
27 ("$_[0]" cmp "$_[1]")
28 },
29238µs283µ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
311300ns$WARNINGS = 0; # 0: suppress, 1: report via warn, 2: report via die
321200ns$VERSION = "2.0116"; # VERSION TEMPLATE: DO NOT CHANGE
33
34222µs254µ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
use constant XML_ERR_NONE => 0;
# spent 30µs making 1 call to XML::LibXML::Error::BEGIN@34 # spent 24µs making 1 call to constant::import
35220µs244µ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
use constant XML_ERR_WARNING => 1; # A simple warning
# spent 25µs making 1 call to XML::LibXML::Error::BEGIN@35 # spent 20µs making 1 call to constant::import
36224µs242µ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
use constant XML_ERR_ERROR => 2; # A recoverable error
# spent 24µs making 1 call to XML::LibXML::Error::BEGIN@36 # spent 19µs making 1 call to constant::import
37225µs244µ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
use constant XML_ERR_FATAL => 3; # A fatal error
# spent 25µs making 1 call to XML::LibXML::Error::BEGIN@37 # spent 19µs making 1 call to constant::import
38
39221µs243µ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
use constant XML_ERR_FROM_NONE => 0;
# spent 24µs making 1 call to XML::LibXML::Error::BEGIN@39 # spent 19µs making 1 call to constant::import
40225µs242µ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
use constant XML_ERR_FROM_PARSER => 1; # The XML parser
# spent 24µs making 1 call to XML::LibXML::Error::BEGIN@40 # spent 18µs making 1 call to constant::import
41220µs244µ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
use constant XML_ERR_FROM_TREE => 2; # The tree module
# spent 25µs making 1 call to XML::LibXML::Error::BEGIN@41 # spent 19µs making 1 call to constant::import
42222µs243µ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
use constant XML_ERR_FROM_NAMESPACE => 3; # The XML Namespace module
# spent 24µs making 1 call to XML::LibXML::Error::BEGIN@42 # spent 19µs making 1 call to constant::import
43223µs242µ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
use constant XML_ERR_FROM_DTD => 4; # The XML DTD validation
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@43 # spent 18µs making 1 call to constant::import
44220µs241µ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
use constant XML_ERR_FROM_HTML => 5; # The HTML parser
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@44 # spent 18µs making 1 call to constant::import
45220µs248µ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
use constant XML_ERR_FROM_MEMORY => 6; # The memory allocator
# spent 26µs making 1 call to XML::LibXML::Error::BEGIN@45 # spent 22µs making 1 call to constant::import
46219µs240µ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
use constant XML_ERR_FROM_OUTPUT => 7; # The serialization code
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@46 # spent 18µs making 1 call to constant::import
47220µs259µ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
use constant XML_ERR_FROM_IO => 8; # The Input/Output stack
# spent 34µs making 1 call to XML::LibXML::Error::BEGIN@47 # spent 25µs making 1 call to constant::import
48220µs242µ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
use constant XML_ERR_FROM_FTP => 9; # The FTP module
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@48 # spent 18µs making 1 call to constant::import
49220µs248µ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
use constant XML_ERR_FROM_HTTP => 10; # The FTP module
# spent 27µs making 1 call to XML::LibXML::Error::BEGIN@49 # spent 22µs making 1 call to constant::import
50220µs240µ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
use constant XML_ERR_FROM_XINCLUDE => 11; # The XInclude processing
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@50 # spent 18µs making 1 call to constant::import
51223µs243µ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
use constant XML_ERR_FROM_XPATH => 12; # The XPath module
# spent 24µs making 1 call to XML::LibXML::Error::BEGIN@51 # spent 19µs making 1 call to constant::import
52223µs243µ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
use constant XML_ERR_FROM_XPOINTER => 13; # The XPointer module
# spent 24µs making 1 call to XML::LibXML::Error::BEGIN@52 # spent 19µs making 1 call to constant::import
53220µs241µ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
use constant XML_ERR_FROM_REGEXP => 14; # The regular expressions module
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@53 # spent 18µs making 1 call to constant::import
54220µs241µ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
use constant XML_ERR_FROM_DATATYPE => 15; # The W3C XML Schemas Datatype module
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@54 # spent 18µs making 1 call to constant::import
55219µs241µ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
use constant XML_ERR_FROM_SCHEMASP => 16; # The W3C XML Schemas parser module
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@55 # spent 18µs making 1 call to constant::import
56224µs241µ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
use constant XML_ERR_FROM_SCHEMASV => 17; # The W3C XML Schemas validation module
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@56 # spent 18µs making 1 call to constant::import
57224µs241µ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
use constant XML_ERR_FROM_RELAXNGP => 18; # The Relax-NG parser module
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@57 # spent 18µs making 1 call to constant::import
58220µs248µ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
use constant XML_ERR_FROM_RELAXNGV => 19; # The Relax-NG validator module
# spent 27µs making 1 call to XML::LibXML::Error::BEGIN@58 # spent 21µs making 1 call to constant::import
59220µs247µ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
use constant XML_ERR_FROM_CATALOG => 20; # The Catalog module
# spent 26µs making 1 call to XML::LibXML::Error::BEGIN@59 # spent 21µs making 1 call to constant::import
60219µs239µ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
use constant XML_ERR_FROM_C14N => 21; # The Canonicalization module
# spent 22µs making 1 call to XML::LibXML::Error::BEGIN@60 # spent 17µs making 1 call to constant::import
61223µs241µ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
use constant XML_ERR_FROM_XSLT => 22; # The XSLT engine from libxslt
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@61 # spent 18µs making 1 call to constant::import
62220µs242µ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
use constant XML_ERR_FROM_VALID => 23; # The DTD validation module with valid context
# spent 24µs making 1 call to XML::LibXML::Error::BEGIN@62 # spent 18µs making 1 call to constant::import
63220µs243µ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
use constant XML_ERR_FROM_CHECK => 24; # The error-checking module
# spent 24µs making 1 call to XML::LibXML::Error::BEGIN@63 # spent 19µs making 1 call to constant::import
64223µs241µ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
use constant XML_ERR_FROM_WRITER => 25; # The xmlwriter module
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@64 # spent 18µs making 1 call to constant::import
65220µs242µ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
use constant XML_ERR_FROM_MODULE => 26; # The dynamically-loaded module module
# spent 24µs making 1 call to XML::LibXML::Error::BEGIN@65 # spent 18µs making 1 call to constant::import
66224µs241µ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
use constant XML_ERR_FROM_I18N => 27; # The module handling character conversion
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@66 # spent 18µs making 1 call to constant::import
67283µs241µ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
use constant XML_ERR_FROM_SCHEMATRONV=> 28; # The Schematron validator module
# spent 23µs making 1 call to XML::LibXML::Error::BEGIN@67 # spent 18µs making 1 call to constant::import
68
6912µ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
781100nsmy $MAX_ERROR_PREV_DEPTH = 100;
79
801700nsfor my $field (qw<code _prev level file line nodename message column context
81 str1 str2 str3 num1 num2 __prev_depth>) {
821512µs my $method = sub { $_[0]{$field} };
832808µs227µ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
no strict 'refs';
# spent 18µs making 1 call to XML::LibXML::Error::BEGIN@83 # spent 9µs making 1 call to strict::unimport
841516µs *$field = $method;
85}
86
87{
88
891200ns 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
190sub int1 { $_[0]->num1 }
191sub int2 { $_[0]->num2 }
192
193sub 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
202sub 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.
2452119µs232µ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
no warnings 'utf8';
# 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
255sub dump {
256 my ($self)=@_;
2572731µs24.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
use Data::Dumper;
# 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
26115µs1;