;~ https://www.autoitscript.com/forum/topic/176895-xmlau3-v-11110-formerly-xmlwrapperexau3-beta-support-topic/?do=findComment&comment=1345368 #include #include "XML.au3" ; This is SetUp for the transfer UDF internal COM Error Handler to the user function _XML_ComErrorHandler_UserFunction(ErrFunc_CustomUserHandler_XML) _Example() Func _Example() Local $sXmlFile = @ScriptDir & "\XML_Example_XML_Files\JPK.xml" Local $oXmlDoc = _XML_CreateDOMDocument(3) _XML_Load($oXmlDoc, $sXmlFile) If @error Then MsgBox($MB_SYSTEMMODAL + $MB_ICONINFORMATION, 'ERR:' & @error & ' EXT:' & @extended, XML_My_ErrorParser(@error, @extended)) MsgBox($MB_SYSTEMMODAL + $MB_ICONINFORMATION, '_XML_Load', _XML_ErrorParser_GetDescription($oXMLDoc)) Return 0 EndIf MsgBox(0, '', _XML_TIDY($oXMLDoc)) Local $iNodeCount = _XML_GetNodesCount($oXMLDoc, "/tns:JPK/tns:Faktura") ConsoleWrite("Group(s): $iNodeCount = " & $iNodeCount & "; @error = " & @error & "; @extended = " & @extended & @LF) Local $aNames = _XML_GetValue($oXMLDoc, "/tns:JPK/tns:Faktura/tns:P_14_1") _ArrayDisplay($aNames, '$aNames') EndFunc ;==>_Example Func XML_My_ErrorParser($iXMLWrapper_Error, $iXMLWrapper_Extended = 0) Local $sErrorInfo = '' Switch $iXMLWrapper_Error Case $XML_ERR_SUCCESS $sErrorInfo = '$XML_ERR_SUCCESS=' & $XML_ERR_SUCCESS & @CRLF & 'All is ok.' Case $XML_ERR_GENERAL $sErrorInfo = '$XML_ERR_GENERAL=' & $XML_ERR_GENERAL & @CRLF & 'The error which is not specifically defined.' Case $XML_ERR_COMERROR $sErrorInfo = '$XML_ERR_COMERROR=' & $XML_ERR_COMERROR & @CRLF & 'COM ERROR OCCURED. Check @extended and your own error handler function for details.' Case $XML_ERR_ISNOTOBJECT $sErrorInfo = '$XML_ERR_ISNOTOBJECT=' & $XML_ERR_ISNOTOBJECT & @CRLF & 'No object passed to function' Case $XML_ERR_INVALIDDOMDOC $sErrorInfo = '$XML_ERR_INVALIDDOMDOC=' & $XML_ERR_INVALIDDOMDOC & @CRLF & 'Invalid object passed to function' Case $XML_ERR_PARSE $sErrorInfo = '$XML_ERR_PARSE=' & $XML_ERR_PARSE & @CRLF & 'Error: with Parsing objects, .parseError.errorCode=' & $iXMLWrapper_Extended & ' Use _XML_ErrorParser_GetDescription() for get details.' Case $XML_ERR_LOAD $sErrorInfo = '$XML_ERR_LOAD=' & $XML_ERR_LOAD & @CRLF & 'Error opening specified file.' Case $XML_ERR_SAVE $sErrorInfo = '$XML_ERR_SAVE=' & $XML_ERR_SAVE & @CRLF & 'Error saving file.' Case $XML_ERR_XPATH $sErrorInfo = '$XML_ERR_XPATH=' & $XML_ERR_XPATH & @CRLF & 'XPath syntax error - check also COM Error Handler.' Case $XML_ERR_DOMVERSION $sErrorInfo = '$XML_ERR_DOMVERSION=' & $XML_ERR_DOMVERSION & @CRLF & 'DOM Version: ' & 'MSXML Version ' & $iXMLWrapper_Extended & ' or greater required for this function' Case $XML_ERR_PARAMETER $sErrorInfo = '$XML_ERR_PARAMETER=' & $XML_ERR_PARAMETER & @CRLF & 'Wrong parameter passed to function.' Case $XML_ERR_ARRAY $sErrorInfo = '$XML_ERR_ARRAY=' & $XML_ERR_ARRAY & @CRLF & 'Wrong array parameter passed to function. Check array dimension and conent.' Case $XML_ERR_NODECREATE $sErrorInfo = '$XML_ERR_NODECREATE=' & $XML_ERR_NODECREATE & @CRLF & 'Can not create Node - check also extended for node type' Case $XML_ERR_NODEAPPEND $sErrorInfo = '$XML_ERR_NODEAPPEND=' & $XML_ERR_NODEAPPEND & @CRLF & 'Can not append Node - check also extended for node type' Case $XML_ERR_EMPTYCOLLECTION $sErrorInfo = '$XML_ERR_EMPTYCOLLECTION=' & $XML_ERR_EMPTYCOLLECTION & @CRLF & 'Collections of objects was empty' Case $XML_ERR_NONODESMATCH $sErrorInfo = '$XML_ERR_NONODESMATCH=' & $XML_ERR_NONODESMATCH & @CRLF & 'No nodes match the XPath expression' Case $XML_ERR_PARSE_XSL $sErrorInfo = '$XML_ERR_PARSE_XSL=' & $XML_ERR_PARSE_XSL & @CRLF & 'Error with Parsing XSL objects .parseError.errorCode=' & $iXMLWrapper_Extended & ' Use _XML_ErrorParser_GetDescription() for get details.' Case $XML_ERR_NOATTRMATCH $sErrorInfo = '$XML_ERR_NOATTRMATCH=' & $XML_ERR_NOATTRMATCH & @CRLF & 'There is no such attribute in selected node.' Case $XML_ERR_NOCHILDMATCH $sErrorInfo = '$XML_ERR_NOCHILDMATCH=' & $XML_ERR_NOCHILDMATCH & @CRLF & 'There is no Child in nodes matched by XPath expression.' Case $XML_ERR_OBJCREATE $sErrorInfo = '$XML_ERR_OBJCREATE=' & $XML_ERR_OBJCREATE & @CRLF & 'Object can not be created.' Case $XML_ERR_INVALIDATTRIB $sErrorInfo = '$XML_ERR_INVALIDATTRIB=' & $XML_ERR_INVALIDATTRIB & @CRLF & 'Invalid object passed to function.' Case $XML_ERR_INVALIDNODETYPE $sErrorInfo = '$XML_ERR_INVALIDNODETYPE=' & $XML_ERR_INVALIDNODETYPE & @CRLF & 'Invalid object passed to function.' Case Else $sErrorInfo = '=' & $iXMLWrapper_Error & @CRLF & 'NO ERROR DESCRIPTION FOR THIS @error' EndSwitch Local $sExtendedInfo = '' Switch $iXMLWrapper_Error Case $XML_ERR_COMERROR $sExtendedInfo = 'COM ERROR NUMBER (@error returned via @extended) =' & $iXMLWrapper_Extended Case $XML_ERR_PARAMETER $sExtendedInfo = 'This @error was fired by parameter: #' & $iXMLWrapper_Extended Case $XML_ERR_INVALIDNODETYPE $sExtendedInfo = 'You are passed to function node.type=' & $iXMLWrapper_Extended Case Else Switch $iXMLWrapper_Extended Case $XML_EXT_DEFAULT $sExtendedInfo = '$XML_EXT_DEFAULT=' & $XML_EXT_DEFAULT & @CRLF & 'Default - Do not return any additional information' Case $XML_EXT_DEFAULT $sExtendedInfo = '$XML_EXT_DEFAULT=' & $XML_EXT_DEFAULT & @CRLF & 'The extended which is not specifically defined.' Case $XML_EXT_XMLDOM $sExtendedInfo = '$XML_EXT_XMLDOM=' & $XML_EXT_XMLDOM & @CRLF & '"Microsoft.XMLDOM" related Error' Case $XML_EXT_DOMDOCUMENT $sExtendedInfo = '$XML_EXT_DOMDOCUMENT=' & $XML_EXT_DOMDOCUMENT & @CRLF & '"Msxml2.DOMDocument" related Error' Case $XML_EXT_XSLTEMPLATE $sExtendedInfo = '$XML_EXT_XSLTEMPLATE=' & $XML_EXT_XSLTEMPLATE & @CRLF & '"Msxml2.XSLTemplate" related Error' Case $XML_EXT_SAXXMLREADER $sExtendedInfo = '$XML_EXT_SAXXMLREADER=' & $XML_EXT_SAXXMLREADER & @CRLF & '"MSXML2.SAXXMLReader" related Error' Case $XML_EXT_MXXMLWRITER $sExtendedInfo = '$XML_EXT_MXXMLWRITER=' & $XML_EXT_MXXMLWRITER & @CRLF & '"MSXML2.MXXMLWriter" related Error' Case $XML_EXT_FREETHREADEDDOMDOCUMENT $sExtendedInfo = '$XML_EXT_FREETHREADEDDOMDOCUMENT=' & $XML_EXT_FREETHREADEDDOMDOCUMENT & @CRLF & '"Msxml2.FreeThreadedDOMDocument" related Error' Case $XML_EXT_XMLSCHEMACACHE $sExtendedInfo = '$XML_EXT_XMLSCHEMACACHE=' & $XML_EXT_XMLSCHEMACACHE & @CRLF & '"Msxml2.XMLSchemaCache." related Error' Case $XML_EXT_STREAM $sExtendedInfo = '$XML_EXT_STREAM=' & $XML_EXT_STREAM & @CRLF & '"ADODB.STREAM" related Error' Case $XML_EXT_ENCODING $sExtendedInfo = '$XML_EXT_ENCODING=' & $XML_EXT_ENCODING & @CRLF & 'Encoding related Error' Case Else $sExtendedInfo = '$iXMLWrapper_Extended=' & $iXMLWrapper_Extended & @CRLF & 'NO ERROR DESCRIPTION FOR THIS @extened' EndSwitch EndSwitch ; return back @error and @extended for further debuging Return SetError($iXMLWrapper_Error, $iXMLWrapper_Extended, _ '@error description:' & @CRLF & _ $sErrorInfo & @CRLF & _ @CRLF & _ '@extended description:' & @CRLF & _ $sExtendedInfo & @CRLF & _ '') EndFunc ;==>XML_My_ErrorParser Func ErrFunc_CustomUserHandler_XML($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : MainScript ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>ErrFunc_CustomUserHandler_MAIN