源码网,源码论坛,源码之家,商业源码,游戏源码下载,discuz插件,棋牌源码下载,精品源码论坛

 找回密码
 立即注册
查看: 437|回复: 17

[ASP编程] javascript asp教程错误处理

[复制链接]

7万

主题

861

回帖

32万

积分

论坛元老

Rank: 8Rank: 8

积分
329525
发表于 2007-3-2 00:00:00 | 显示全部楼层 |阅读模式

The ASPError Object has zero (0) Methods, nine (9) Properties, zero (0) Events, and zero (0) Collections.

AspCode
AspDescription
Category
Column
Description
File
Line
Number
Source

The way you access the ASPError Properties is with a Server Method. Yeah, I know; it doesn't make sense. Start with something like var myError=Server.GetLastError() and then you can access all nine ASPError Properties following this pattern: <%=myError.Line%>.

Below is the script for Lesson 15.

<%@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.")
	}
%>

Click Here to run the script in a new window.

Okay, so what happened to On Error Resume Next? Sorry, that ain't no JavaScript thing. So, what about onerror? 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 try { } statements and the what-to-do in the event of an error goes inside the catch { } statement. There is also a finally { } statement (optional). The whole thing is just as graceful as On Error (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.

回复

使用道具 举报

7

主题

1万

回帖

398

积分

中级会员

Rank: 3Rank: 3

积分
398
发表于 2022-9-23 17:43:25 | 显示全部楼层
sdsadsadsadf
回复 支持 反对

使用道具 举报

29

主题

1万

回帖

194

积分

注册会员

Rank: 2

积分
194
发表于 2022-10-1 09:05:12 | 显示全部楼层
66666666666
回复 支持 反对

使用道具 举报

2

主题

1万

回帖

381

积分

中级会员

Rank: 3Rank: 3

积分
381
发表于 2022-12-31 21:19:47 | 显示全部楼层
这个源码还可以
回复 支持 反对

使用道具 举报

12

主题

1万

回帖

431

积分

中级会员

Rank: 3Rank: 3

积分
431
发表于 2023-5-7 06:55:57 | 显示全部楼层
额UI废物iuhfujewfiewnnfen
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

0

积分

中级会员

Rank: 3Rank: 3

积分
0
发表于 2023-8-29 22:39:37 | 显示全部楼层
而非为吾问无为谓娃娃
回复 支持 反对

使用道具 举报

0

主题

1万

回帖

100

积分

注册会员

Rank: 2

积分
100
发表于 2023-9-8 18:05:03 | 显示全部楼层
dfdsafdsfdsfdsf
回复 支持 反对

使用道具 举报

4

主题

1万

回帖

58

积分

注册会员

Rank: 2

积分
58
发表于 2023-10-21 06:03:37 | 显示全部楼层
有什么好的服务器
回复 支持 反对

使用道具 举报

2

主题

1万

回帖

73

积分

注册会员

Rank: 2

积分
73
发表于 2023-12-7 01:14:12 | 显示全部楼层
而快乐你们快乐马年快乐
回复 支持 反对

使用道具 举报

15

主题

1万

回帖

122

积分

注册会员

Rank: 2

积分
122
发表于 2023-12-12 03:43:11 | 显示全部楼层
的谁vdvdsvdsvdsdsv
回复 支持 反对

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

手机版|小黑屋|网站地图|源码论坛 ( 海外版 )

GMT+8, 2024-9-21 08:17 , Processed in 0.090266 second(s), 26 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表