以任何方式检查当前的On Error状态 [英] Any way to check current On Error status

查看:66
本文介绍了以任何方式检查当前的On Error状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图弄清楚是否有办法生成标准错误处理程序

知道如果调用代码在决定如何响应之前有错误处理程序(On Error Goto

< label>或On Error Resume Next)。有没有人

知道这是否可行。

I''m trying to figure out if there is a way to generate standard error handlers
that "know" if the calling code has an error handler in effect (On Error Goto
<label> or On Error Resume Next) before deciding how to respond. Does anyone
know if this is possible.

推荐答案

On Sun,2004年6月6日02:44:11 GMT, Steve Jorgensen

< no **** @ nospam.nospam>写道:


如果你告诉我们你为什么需要这个,也许我们可以做出更好的回应。


简答:是的,但你''我需要跟踪调用堆栈

你自己。


-Tom。

On Sun, 06 Jun 2004 02:44:11 GMT, Steve Jorgensen
<no****@nospam.nospam> wrote:

If you tell us why you need this, perhaps we can respond better.

Short answer: yes, but you''ll need to keep track of the call stack
yourself.

-Tom.

我想弄清楚是否有办法生成标准错误处理程序
知道如果调用代码在决定如何响应之前有错误处理程序(On Error Goto
< label>或On Error Resume Next)。有没有人知道这是否可行。
I''m trying to figure out if there is a way to generate standard error handlers
that "know" if the calling code has an error handler in effect (On Error Goto
<label> or On Error Resume Next) before deciding how to respond. Does anyone
know if this is possible.






2004年6月5日星期六20:50:17 -0700,汤姆van Stiphout< to ***** @ no.spam.cox.net>

写道:
On Sat, 05 Jun 2004 20:50:17 -0700, Tom van Stiphout <to*****@no.spam.cox.net>
wrote:
On Sun,2004年6月6日02:44 :11 GMT,Steve Jorgensen
< no **** @ nospam.nospam>写道:

如果你告诉我们你为什么需要这个,也许我们可以做出更好的回应。

简答:是的,但你需要跟踪电话堆栈
自己。

-Tom。

On Sun, 06 Jun 2004 02:44:11 GMT, Steve Jorgensen
<no****@nospam.nospam> wrote:

If you tell us why you need this, perhaps we can respond better.

Short answer: yes, but you''ll need to keep track of the call stack
yourself.

-Tom.

我正在试图弄清楚是否有办法生成标准错误处理程序
知道如果调用代码在决定如何响应之前有错误处理程序(On Error Goto
< label>或On Error Resume Next)。有没有人知道这是否可行。
I''m trying to figure out if there is a way to generate standard error handlers
that "know" if the calling code has an error handler in effect (On Error Goto
<label> or On Error Resume Next) before deciding how to respond. Does anyone
know if this is possible.




基本上,我正在努力减少错误的标准变化数量

处理代码块我需要在一个应用程序中实现,该应用程序将在Access运行时环境中正常且适当地运行和处理

错误。


现在的冲突是在2个标准情况之间:

1.任何代码(特殊情况除外)将执行以响应用户

事件必须具有错误处理程序,显示错误消息(可能

记录错误等)并在程序退出点恢复。

2.其他代码调用的任何代码应该,默认情况下,重新将错误提升到

调用代码,将其程序名称添加到Source以显示调用堆栈。


如果你使用2在哪里你应该使用1,调用代码可以在

假设被调用的代码正确地完成它的工作,这可能是一个

危险的假设,当它没有。此外,在不同情况下可能会出现案件1或案例2的情况。


我希望有的是一个错误处理块,它知道显示一个

消息,如果没有错误处理程序在调用代码时生效则退出,并且如果有一个错误处理块,则重新引发错误调用代码中生效的错误处理程序。



Basically, I''m trying to reduce the number of standard variations of error
handling code block I need to implement in an app that will run and handle
errors gracefully and appropriately in the Access run-time environment.

The conflict now, is between 2 standard cases:
1. Any code (except special cases) that will execute in response to a user
event must have an error handler that displays an error message (possibly
logging the error, etc.) and resumes at the procedure exit point.
2. Any code called by other code should, by default, re-raise the error to
calling code, adding its procedure name to the Source to show the call stack.

If you use 2 where you should use 1, the calling code may proceed on the
assumption that the called code did its job correctly, and this can be a
dangerous assumption when it didn''t. Furthermore, there can be cases where a
procedure may be either case 1 or case 2 in different circumstances.

What I''m hoping to have is an error handling block that knows to display a
message and exit if no error handler is in effect in calling code, and to
re-raise the error if there is an error handler in effect in the calling code.


On Sun,2004年6月6日04:56:18 GMT,Steve Jorgensen

< no ****@nospam.nospam>写道:


如果你用Push和Pop函数来装备每一个proc并且

在堆栈上和堆栈外弹出它的名字,你会通过一个额外的

参数,指示此proc是否正在使用错误处理程序,

然后你可以在错误处理块中遍历该堆栈并检查

是否存在错误处理程序。


不幸的是,与.NET环境不同,在Access中你没有

访问堆栈,所以上面做了类似的事情很难

方式。


就个人而言,我并没有区分案例1和案例2 ,和

我永远实施案例1.


-Tom。

On Sun, 06 Jun 2004 04:56:18 GMT, Steve Jorgensen
<no****@nospam.nospam> wrote:

If you outfit every proc with a Push and a Pop function to push and
pop its name on and off the stack, and you would pass an extra
argument indicating if this proc is using an error handler or not,
then you could in an error handling block walk that stack and check
the presence or absence of an error handler.

Unfortunately, unlike the .NET environment, in Access you don''t have
access to the stack, so the above is doing a similar thing the hard
way.

Personally, I don''t make a distinction between case 1 and case 2, and
I "always" implement case 1.

-Tom.

2004年6月5日星期六20:50:17 -0700,汤姆van Stiphout< to ***** @ no.spam.cox.net>
写道:
On Sat, 05 Jun 2004 20:50:17 -0700, Tom van Stiphout <to*****@no.spam.cox.net>
wrote:
On Sun,2004年6月6日02:44:11 GMT, Steve Jorgensen
< no **** @ nospam.nospam>写道:

如果你告诉我们你为什么需要这个,也许我们可以做出更好的回应。

简答:是的,但你需要跟踪电话堆栈
自己。

-Tom。

On Sun, 06 Jun 2004 02:44:11 GMT, Steve Jorgensen
<no****@nospam.nospam> wrote:

If you tell us why you need this, perhaps we can respond better.

Short answer: yes, but you''ll need to keep track of the call stack
yourself.

-Tom.

我正在试图弄清楚是否有办法生成标准错误处理程序
知道如果调用代码在决定如何响应之前有错误处理程序(On Error Goto
< label>或On Error Resume Next)。有没有人知道这是否可行。
I''m trying to figure out if there is a way to generate standard error handlers
that "know" if the calling code has an error handler in effect (On Error Goto
<label> or On Error Resume Next) before deciding how to respond. Does anyone
know if this is possible.



基本上,我正在努力减少错误的标准变体数量处理代码我需要在一个应用程序中实现,该应用程序将在Access运行时环境中正常且适当地运行和处理错误。

现在的冲突是在2个标准情况之间:
1。任何代码(特殊情况除外)将响应用户
事件而执行必须有一个错误处理程序,显示错误消息(可能记录错误等)并在程序出口点恢复。
2。默认情况下,其他代码调用的任何代码都应该重新将错误提升为调用代码,将其过程名称添加到Source以显示调用堆栈。

如果使用2你应该使用1,调用代码可以继续假设被调用的代码正确地完成它的工作,这可能是一个危险的假设,当它没有。此外,在不同的情况下,可能会出现案例1或案例2的情况。

我希望有一个知道要显示的错误处理块如果在调用代码时没有错误处理程序生效,则退出并退出;如果调用代码中存在错误处理程序,则重新引发错误。



Basically, I''m trying to reduce the number of standard variations of error
handling code block I need to implement in an app that will run and handle
errors gracefully and appropriately in the Access run-time environment.

The conflict now, is between 2 standard cases:
1. Any code (except special cases) that will execute in response to a user
event must have an error handler that displays an error message (possibly
logging the error, etc.) and resumes at the procedure exit point.
2. Any code called by other code should, by default, re-raise the error to
calling code, adding its procedure name to the Source to show the call stack.

If you use 2 where you should use 1, the calling code may proceed on the
assumption that the called code did its job correctly, and this can be a
dangerous assumption when it didn''t. Furthermore, there can be cases where a
procedure may be either case 1 or case 2 in different circumstances.

What I''m hoping to have is an error handling block that knows to display a
message and exit if no error handler is in effect in calling code, and to
re-raise the error if there is an error handler in effect in the calling code.






这篇关于以任何方式检查当前的On Error状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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