Handling XML Parser Errors in ASP

The following code from menu.asp handles parser errors returned by instances of the XML DOM. The code references the XMLDOMParseError object. When an error occurs during the processing of XML or XSL files that menu.asp stores in XML document objects, the reportError subroutine is called. The reportError subroutine accepts the value returned by the parseError property, a long integer, and sends an HTML stream to the browser with details about the error. The following code fragment illustrates this process:

Set errXML = oXML.parseError
   If errXML.errorCode <> 0 Then reportError(errXML)

   Set errXSL = oXSL.parseError
   If errXSL.errorCode <> 0 Then reportError(errXSL)
   
  Sub reportError(perr)
   Dim serr
   serr  = "CODE: " & perr.errorCode & "<br>"
   serr = serr & "URL: " & perr.url & "<br>"
   serr = serr & "LINE: " & perr.line & "<br>"
   serr = serr & "SRCTEXT:"  & perr.srcText & "<br>"
   serr = serr & "REASON: " & perr.reason
   Response.Write serr
End Sub