是的try-catch类似的错误在ASP经典的处理可能吗? [英] Is try-catch like error handling possible in ASP Classic?

查看:154
本文介绍了是的try-catch类似的错误在ASP经典的处理可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪些选项中有 ASP经典错误处理?

What options are there in ASP Classic for error handling?

例如:

我使用了 Mail.SendMail 的功能,但在测试服务器上进行切换时它不工作,这是正常的。我想测试,如果邮件是可能的,如果没有则继续和/或显示的消息。

I'm using the Mail.SendMail function but when switching on the testing server it doesn't work, which is normal. I want to test if mailing is possible, if not then continue and/or show a message.

任何想法?

推荐答案

有两种方法,你可以美元的JScript或VBScript C $ç这确实有构造或者你可以在你的code做傻事了。

There are two approaches, you can code in JScript or VBScript which do have the construct or you can fudge it in your code.

使用JScript你会使用下列类型的构造:

Using JScript you'd use the following type of construct:

<script language="jscript" runat="server">
try {
      tryStatements}
catch(exception){
      catchStatements}
finally {
      finallyStatements}
</script>

在你的ASP code,你通过像抓点上使用错误的简历在旁边点,你就会有一个尝试和检查Err.Number的捏造吧:

In your ASP code you fudge it by using on error resume next at the point you'd have a try and checking err.Number at the point of a catch like:

<%
Dim i
' Turn on error Handling
On Error Resume Next


'Code here that you want to catch errors from

' Error Handler
If Err.Number <> 0 Then
   ' Error Occurred / Trap it
   On Error Goto 0 ' But don't let other errors hide!
   ' Code to cope with the error here
End If
On Error Goto 0 ' Reset error handling.

%>

这篇关于是的try-catch类似的错误在ASP经典的处理可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆