简体   繁体   English

On Error Goto引发错误

[英]On Error Goto throws error

There are similar questions about On Error Goto x not catching all errors etc, but I've encountered a different problem. 关于On Error Goto x不能捕获所有错误等也有类似的问题,但是我遇到了一个不同的问题。

My (Classic ASP) page works fine, most of the time. 我的(经典ASP)页面在大多数情况下都能正常运行。 Some users complain of an error on the page, couldn't duplicate yet. 一些用户抱怨页面上的错误,目前无法复制。

I tried error handling but On Error Resume Next does not help me with this situation and On Error Goto causes the page not to work and constantly throw an error (which looks like a 500, but that might be because of handling IIS is doing in background). 我尝试了错误处理,但是On Error Resume Next执行On Error Resume Next对这种情况没有帮助,并且On Error Goto导致页面无法正常工作并不断抛出错误(看起来像是500,但这可能是由于处理IIS在后台执行的缘故) )。 It happens whether I write Goto 0 or Goto [label] without a difference if the label exists or not. 无论Goto [label]是否存在,我写Goto 0Goto [label]发生差异。

What might be causing this? 是什么原因造成的?

On Error GoTo label is not supported in ASP ASP中不支持出现On Error GoTo label

you begin an error trapping block using 您开始使用一个错误捕获块

On Error Resume Next , On Error Resume Next

check Err.Number to see if an error occurred, 检查Err.Number以查看是否发生错误,

close the block using 使用关闭块

On Error GoTo 0 . On Error GoTo 0

See this doc and this thread 看到这个文档这个线程

Trying to trap every error using On Error Resume Next is not practical in larger ASP pages. 尝试使用On Error Resume Next捕获每个错误在较大的ASP页面中不切实际。

Configure IIS to use a custom error page if a status code 500 is received. 如果收到状态码500,则将IIS配置为使用自定义错误页面。 Format the following to suit... 格式化以下内容以适合...

Set objASPError = Server.GetLastError

response.write "Category: " & objASPError.Category & _
 "ASPCode: " & objASPError.ASPCode & _
 "Number: " & objASPError.Number & _
 "ASPDescription: " & objASPError.ASPDescription & _
 "Description: " & objASPError.Description & _
 "Source: " & objASPError.Source

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM