| AspCode |
| AspDescription |
| Category |
| Column |
| Description |
| File |
| Line |
| Number |
| Source |
<%@LANGUAGE="JavaScript"%>
<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<%
try
{
Response.Write("<STRONG>Use <I>GetLastError( )</I><BR></STRONG>\r")
myError = Server.GetLastError()
Response.Write("myError.Line: " + myError.Line + "<BR>\r")
Response.Write("myError.File: " + myError.File + "\r")
Response.Write("<HR>\r<STRONG>")
Response.Write("Now an intentional error...")
Response.Write("<BR></STRONG>\r")
myError = erver.GetLastError() //this line causes an error
Response.Write("myError.Line: " + myError.Line + "<BR>\r")
Response.Write("myError.File: " + myError.File + "<BR>\r")
}
catch(myDumbError)
{
Response.Write("There is an error: " + myDumbError)
%>
<BR>
Graceful error handling goes here (inside the catch statement).
Make it as simple or sophisticated as you like.<BR>
<HR>
<STRONG>Now let's break down the error Object.</STRONG><BR>
<%
for ( var i in myDumbError)
{
Response.Write(i + ": " + myDumbError[i] + "<BR>\r")
}
}
finally
{
Response.Write("<HR><STRONG>Let's Finish Up.</STRONG><BR>\r")
Response.Write("Code inside the <I>finally { }</I> statement ")
Response.Write("executes regardless of error (or lack thereof). \r")
Response.Write("<I>finally{ }</I> is totally optional. ")
Response.Write("It's a good place for things like RS.Close()... ")
Response.Write("which you'll see later on.")
}
%>
[url=javascript:lesson(]Click Here[/url] to run the script in a new window.
Okay, so what happened to [i]On Error Resume Next[/i]? Sorry, that ain't no JavaScript thing. So, what about [i]onerror[/i]? That won't work on the server side. But thanks to some core JavaScript we have some error handling.
The section of script for which you wish to provide error handling goes inside the [i]try { }[/i] statements and the what-to-do in the event of an error goes inside the [i]catch { }[/i] statement. There is also a [i]finally { }[/i] statement (optional). The whole thing is just as graceful as [i]On Error[/i] (in my opinion).
Not every ASP server allows you access to the ASPError Object. So, don't be surprised if ASPError gives you an error.
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有