{"id":7019,"date":"2022-12-20T19:34:39","date_gmt":"2022-12-20T22:34:39","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/xmllibxmlerror-man3\/"},"modified":"2022-12-20T19:34:39","modified_gmt":"2022-12-20T22:34:39","slug":"xmllibxmlerror-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/xmllibxmlerror-man3\/","title":{"rendered":"XML::LibXML::Error (man3)"},"content":{"rendered":"<h1 align=\"center\">XML::LibXML::Error<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#AUTHORS\">AUTHORS<\/a><br \/> <a href=\"#VERSION\">VERSION<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a><br \/> <a href=\"#LICENSE\">LICENSE<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">XML::LibXML::Error \u2212 Structured Errors<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">eval { &#8230; }; <br \/> if (ref($@)) { <br \/> # handle a structured error (XML::LibXML::Error object) <br \/> } elsif ($@) { <br \/> # error, but not an XML::LibXML::Error object <br \/> } else { <br \/> # no error <br \/> } <br \/> $XML::LibXML::Error::WARNINGS=1; <br \/> $message = $@\u2212>as_string(); <br \/> print $@\u2212>dump(); <br \/> $error_domain = $@\u2212>domain(); <br \/> $error_code = $@\u2212>code(); <br \/> $error_message = $@\u2212>message(); <br \/> $error_level = $@\u2212>level(); <br \/> $filename = $@\u2212>file(); <br \/> $line = $@\u2212>line(); <br \/> $nodename = $@\u2212>nodename(); <br \/> $error_str1 = $@\u2212>str1(); <br \/> $error_str2 = $@\u2212>str2(); <br \/> $error_str3 = $@\u2212>str3(); <br \/> $error_num1 = $@\u2212>num1(); <br \/> $error_num2 = $@\u2212>num2(); <br \/> $string = $@\u2212>context(); <br \/> $offset = $@\u2212>column(); <br \/> $previous_error = $@\u2212>_prev();<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The XML::LibXML::Error class is a tiny frontend to <i>libxml2<\/i>\u2019s structured error support. If XML::LibXML is compiled with structured error support, all errors reported by libxml2 are transformed to XML::LibXML::Error objects. These objects automatically serialize to the corresponding error messages when printed or used in a string operation, but as objects, can also be used to get a detailed and structured information about the error that occurred.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Unlike most other XML::LibXML objects, XML::LibXML::Error doesn\u2019t wrap an underlying <i>libxml2<\/i> structure directly, but rather transforms it to a blessed Perl hash reference containing the individual fields of the structured error information as hash key-value pairs. Individual items (fields) of a structured error can either be obtained directly as $@\u2212>{field}, or using autoloaded methods such as $@\u2212><b>field()<\/b> (where field is the field name). XML::LibXML::Error objects have the following fields: domain, code, level, file, line, nodename, message, str1, str2, str3, num1, num2, and _prev (some of them may be undefined). <br \/> $XML::LibXML::Error::WARNINGS<\/p>\n<p style=\"margin-left:17%;\">$XML::LibXML::Error::WARNINGS=1;<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Traditionally, XML::LibXML was suppressing parser warnings by setting libxml2\u2019s global variable xmlGetWarningsDefaultValue to 0. Since 1.70 we do not change libxml2\u2019s global variables anymore; for backward compatibility, XML::LibXML suppresses warnings. This variable can be set to 1 to enable reporting of these warnings via Perl &#8220;warn&#8221; and to 2 to report hem via &#8220;die&#8221;.<\/p>\n<p style=\"margin-left:11%;\">as_string<\/p>\n<p style=\"margin-left:17%;\">$message = $@\u2212>as_string();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This function serializes an XML::LibXML::Error object to a string containing the full error message close to the message produced by <i>libxml2<\/i> default error handlers and tools like xmllint. This method is also used to overload &#8220;&#8221; operator on XML::LibXML::Error, so it is automatically called whenever XML::LibXML::Error object is treated as a string (e.g. in print $@).<\/p>\n<p style=\"margin-left:11%;\">dump<\/p>\n<p style=\"margin-left:17%;\">print $@\u2212>dump();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This function serializes an XML::LibXML::Error to a string displaying all fields of the error structure individually on separate lines of the form \u2019name\u2019 => \u2019value\u2019.<\/p>\n<p style=\"margin-left:11%;\">domain<\/p>\n<p style=\"margin-left:17%;\">$error_domain = $@\u2212>domain();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Returns string containing information about what part of the library raised the error. Can be one of: &#8220;parser&#8221;, &#8220;tree&#8221;, &#8220;namespace&#8221;, &#8220;validity&#8221;, &#8221; <small>HTML<\/small> parser&#8221;, &#8220;memory&#8221;, &#8220;output&#8221;, &#8220;I\/O&#8221;, &#8220;ftp&#8221;, &#8220;http&#8221;, &#8220;XInclude&#8221;, &#8220;XPath&#8221;, &#8220;xpointer&#8221;, &#8220;regexp&#8221;, &#8220;Schemas datatype&#8221;, &#8220;Schemas parser&#8221;, &#8220;Schemas validity&#8221;, &#8220;Relax-NG parser&#8221;, &#8220;Relax-NG validity&#8221;, &#8220;Catalog&#8221;, &#8220;C14N&#8221;, &#8221; <small>XSLT&#8221;,<\/small> &#8220;validity&#8221;.<\/p>\n<p style=\"margin-left:11%;\">code<\/p>\n<p style=\"margin-left:17%;\">$error_code = $@\u2212>code();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Returns the actual libxml2 error code. The XML::LibXML::ErrNo module defines constants for individual error codes. Currently libxml2 uses over 480 different error codes.<\/p>\n<p style=\"margin-left:11%;\">message<\/p>\n<p style=\"margin-left:17%;\">$error_message = $@\u2212>message();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Returns a human-readable informative error message.<\/p>\n<p style=\"margin-left:11%;\">level<\/p>\n<p style=\"margin-left:17%;\">$error_level = $@\u2212>level();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Returns an integer value describing how consequent is the error. XML::LibXML::Error defines the following constants:<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"62%\">\n<p><small>XML_ERR_NONE<\/small> = 0<\/p>\n<\/td>\n<td width=\"15%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"62%\">\n<p><small>XML_ERR_WARNING<\/small> = 1 : A simple warning.<\/p>\n<\/td>\n<td width=\"15%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"62%\">\n<p><small>XML_ERR_ERROR<\/small> = 2 : A recoverable error.<\/p>\n<\/td>\n<td width=\"15%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"17%\"><\/td>\n<td width=\"1%\">\n<p>\u2022<\/p>\n<\/td>\n<td width=\"5%\"><\/td>\n<td width=\"62%\">\n<p><small>XML_ERR_FATAL<\/small> = 3 : A fatal error.<\/p>\n<\/td>\n<td width=\"15%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:11%;\">file<\/p>\n<p style=\"margin-left:17%;\">$filename = $@\u2212>file();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Returns the filename of the file being processed while the error occurred.<\/p>\n<p style=\"margin-left:11%;\">line<\/p>\n<p style=\"margin-left:17%;\">$line = $@\u2212>line();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">The line number, if available.<\/p>\n<p style=\"margin-left:11%;\">nodename<\/p>\n<p style=\"margin-left:17%;\">$nodename = $@\u2212>nodename();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Name of the node where error occurred, if available. When this field is non-empty, libxml2 actually returned a physical pointer to the specified node. Due to memory management issues, it is very difficult to implement a way to expose the pointer to the Perl level as a XML::LibXML::Node. For this reason, XML::LibXML::Error currently only exposes the name the node.<\/p>\n<p style=\"margin-left:11%;\">str1<\/p>\n<p style=\"margin-left:17%;\">$error_str1 = $@\u2212>str1();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Error specific. Extra string information.<\/p>\n<p style=\"margin-left:11%;\">str2<\/p>\n<p style=\"margin-left:17%;\">$error_str2 = $@\u2212>str2();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Error specific. Extra string information.<\/p>\n<p style=\"margin-left:11%;\">str3<\/p>\n<p style=\"margin-left:17%;\">$error_str3 = $@\u2212>str3();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Error specific. Extra string information.<\/p>\n<p style=\"margin-left:11%;\">num1<\/p>\n<p style=\"margin-left:17%;\">$error_num1 = $@\u2212>num1();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Error specific. Extra numeric information.<\/p>\n<p style=\"margin-left:11%;\">num2<\/p>\n<p style=\"margin-left:17%;\">$error_num2 = $@\u2212>num2();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">In recent libxml2 versions, this value contains a column number of the error or 0 if N\/A.<\/p>\n<p style=\"margin-left:11%;\">context<\/p>\n<p style=\"margin-left:17%;\">$string = $@\u2212>context();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">For parsing errors, this field contains about 80 characters of the <small>XML<\/small> near the place where the error occurred. The field &#8220;$@\u2212>column()&#8221; contains the corresponding offset. Where N\/A, the field is undefined.<\/p>\n<p style=\"margin-left:11%;\">column<\/p>\n<p style=\"margin-left:17%;\">$offset = $@\u2212>column();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">See &#8220;$@\u2212>column()&#8221; above.<\/p>\n<p style=\"margin-left:11%;\">_prev<\/p>\n<p style=\"margin-left:17%;\">$previous_error = $@\u2212>_prev();<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This field can possibly hold a reference to another XML::LibXML::Error object representing an error which occurred just before this error.<\/p>\n<h2>AUTHORS <a name=\"AUTHORS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Matt Sergeant, Christian Glahn, Petr Pajas<\/p>\n<h2>VERSION <a name=\"VERSION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">2.0206<\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">2001\u22122007, AxKit.com Ltd.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">2002\u22122006, Christian Glahn.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">2006\u22122009, Petr Pajas.<\/p>\n<h2>LICENSE <a name=\"LICENSE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This program is free software; you can redistribute it and\/or modify it under the same terms as Perl itself.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  XML::LibXML::Error \u2212 Structured Errors <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3007,3369],"class_list":["post-7019","post","type-post","status-publish","format-standard","hentry","category-sin-categoria","tag-man3","tag-xmllibxmlerror"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7019","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7019"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7019\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7019"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7019"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7019"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}