精华区 [关闭][返回]

当前位置:月光软件>>讨论区精华>>〖软件开发〗>>● ASP>>★ASP的技巧★>>错误信息>>[转] ASP3.0错误处理(英)

主题:[转] ASP3.0错误处理(英)
发信人: dongbao(永远的似水流年)
整理人: dongbao(2002-04-19 17:02:23), 站内信件
Error Handling capabilities are made superior in ASP 3.0 By providing exception handling of Jscript and ASPError object. The following article describes in detail the method of using ASPError Object. 

ASP 3.0 provides us with an intrinsic object called ASPError object to trap the scripterrors, preprocessing and runtime errors occuring in ASP page. ASPError object is invoked implicitly by calling GetLastError() method of 
Server Object. ASPError object is provided with many methods to give an detailed description about the error and, the ASP Page giving raise to error. 

ASPError object has seven properties which are given below 



ASPCode : Error code that was generated by IIS 5.0 and the subsystem within the IIS. 


Number : When a COMponent generates the error, number will contain the COM error number, eg 80005008 , but displayed as an integer. Number may also hold a value if a COM object indirectly used by the site, eg the JScript 
Engine, generates an error. 


Source : This indicates what generated the error, IIS, scripting, or a COM object. 


FileName : The name of the ASP file that generated the error. 


LineNumber : The line number in the ASP file where the error was generated. 


Description : This is a description of why the error occurred - usually a phrase that indicates what it wanted to do or expected to process. Eg, 'Expected End If' 


ASPDescription : An error string that is generated by the IIS or by the ASP object model. 


Let us explore ASPError Object by taking an example 

Sample.asp 

<%@ language = "VbScript" %>

<HTML>
<HEAD>
<title>Samplepage</title>
</HEAD>
<BODY>
<%

'Include any statement that creates an error
'The following code creates HTTP 500 error

dim k for k=1 to 1 next

'trap the error by invoking ASPError object
'This is done by calling GetLastError() method of Server Object

erobj = server.GetLastError()

'The variable erobj contains ASPError object


%>

<P>In error file</P>
<TABLE>
<TR><TD>ASP Code </TD><TD> <%= erobj.ASPCode %> </TD></TR>
<TR><TD>Number </TD><TD> <%= erobj.Number %> </TD></TR>
<TR><TD>Source </TD><TD> <%= erobj.Source %> </TD></TR>
<TR><TD>FileName </TD><TD> <%= erobj.FileName %> </TD></TR>
<TR><TD>LineNumber </TD><TD> <%= erobj.LineNumber %> </TD></TR>
<TR><TD>Description </TD><TD> <%= erobj.Description %> </TD></TR>
<TR><TD>ASP Description </TD><TD> <%= erobj.ASPDescription %> </TD></TR>
</TABLE>
</BODY>
</HTML>

When the sample.asp file is executed the Error details occcured in the page are displayed in the browser by calling ASPError object. 


----

ICQ:43395237 OICQ:126132(read-only)    
我自豪我用正版,我骄傲我用盗版!!!
  

[关闭][返回]






转载请注明:转载自 月光程序代码网 [ http://www.moon-soft.com ]