捕获代码时出错 [英] Error trapping code

查看:58
本文介绍了捕获代码时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我广泛使用代码;我可能过度使用了它。但是我一直在使用

错误捕获错误,现在我被困在那里。


一个适用于我的表格我正在使用的系统,显然会在实际使用它的系统上遇到问题,而且由于我使用了很少的错误捕获,所以它很难消失非常好。


我当然会尝试修复导致错误的任何内容并添加

错误捕获到问题所在的函数,但是我

意识到我需要添加一个更宽松的错误捕获代码

手。


因此,我的问题应该是错误捕获代码书挡每个子

和函数?如果没有,我用什么标准决定是否添加



- 谢谢,thelma

解决方案

是的,如果应用程序很重要,请在应用程序中的每个sub和

函数中使用错误捕获。


-

Allen Browne - 微软MVP。西澳大利亚州珀斯。

访问用户提示 - http:// allenbrowne.com/tips.html

回复群组,而不是mvps dot org的allenbrowne。


Thelma Lubkin <第**** @ alpha2.csd.uwm.edu>在消息中写道

news:df ********** @ uwm.edu ...

我广泛使用代码;我可能过度使用了它。但是我一直在使用
错误陷阱,现在我已被困在那里了。

在我正在使用的系统上对我有用的表格,显然在实际使用它的系统上会遇到问题,因为我使用了很少的错误捕获它会非常不合理地死掉。

我当然会尝试修复导致错误的任何问题,并将错误捕获添加到问题所在的函数中,但是我意识到我需要添加错误捕获代码以及更自由的手。

因此,我的问题是,错误捕获代码是否应该为每个子和功能提供支持?如果没有,我用什么标准决定是否添加它?
- 谢谢,thelma



Thelma Lubkin写道:

因此,我的问题是,错误捕获代码是否应该为每个子设备和功能服务?如果没有,我使用什么标准来决定是否添加它?




函数,将值返回给调用过程的方法,don '
必然需要错误处理,但调用代码肯定应该是b $ b b。对象(类模块)应该捕获错误并将其传递给客户端代码




blockquote>

是在

之后,有一种简单的方法可以将基本错误捕获插入到所有潜艇中吗?只是基本的:msgbox err.number&错误的描述内容

" Allen Browne" <铝********* @ SeeSig.Invalid>在消息中写道

news:43 ********************* @ per-qv1-newsreader-01.iinet.net.au。 ..

是的,如果应用程序很重要,请在应用程序的每个子和
函数中使用错误捕获。

-
Allen Browne - 微软MVP。西澳大利亚州珀斯。
访问用户提示 - http://allenbrowne.com/ tips.html
回复群组,而不是在mvps dot org的allenbrowne。

Thelma Lubkin <第**** @ alpha2.csd.uwm.edu>在消息中写道
新闻:df ********** @ uwm.edu ...

我广泛使用代码;我可能过度使用了它。但是我一直在使用
错误陷阱,现在我已被困在那里了。

在我正在使用的系统上对我有用的表格,显然在实际使用它的系统上会遇到问题,因为我使用了很少的错误捕获它会非常不合理地死掉。

我当然会尝试修复导致错误的任何问题,并将错误捕获添加到问题所在的函数中,但是我意识到我需要添加错误捕获代码以及更自由的手。

因此,我的问题是,错误捕获代码是否应该为每个子和功能提供支持?如果没有,我用什么标准来决定是否添加它?
- 谢谢,thelma




I use code extensively; I probably overuse it. But I''ve been using
error trapping very sparingly, and now I''ve been trapped by that.

A form that works for me on the system I''m using, apparently runs into
problems on the system where it will actually be used, and since I
used so little error-trapping it dies very ungracefully.

I will of course try to fix whatever is causing the error and add
error-trapping to the functions where the problem surfaces, but I
realize that I need to add error-trapping code with a more liberal
hand.

My question is, therefore, should error-trapping code bookend every sub
and function? If not, what criteria do I use to decide whether to add
it or not?
--thanks, thelma

解决方案

Yes, if the application matters, use error-trapping in every sub and
function in your application.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message
news:df**********@uwm.edu...

I use code extensively; I probably overuse it. But I''ve been using
error trapping very sparingly, and now I''ve been trapped by that.

A form that works for me on the system I''m using, apparently runs into
problems on the system where it will actually be used, and since I
used so little error-trapping it dies very ungracefully.

I will of course try to fix whatever is causing the error and add
error-trapping to the functions where the problem surfaces, but I
realize that I need to add error-trapping code with a more liberal
hand.

My question is, therefore, should error-trapping code bookend every sub
and function? If not, what criteria do I use to decide whether to add
it or not?
--thanks, thelma



Thelma Lubkin wrote:

My question is, therefore, should error-trapping code bookend every sub
and function? If not, what criteria do I use to decide whether to add
it or not?



Functions, methods that return a value to a calling procedure, don''t
necessarily need error handling, but the calling code certainly should
have it. Objects(class modules) should trap an error and pass it on to
the client code.



Is there an easy way to insert basic error trapping into all subs after the
fact? Just the basic : msgbox err.number & err.description stuff
"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:43*********************@per-qv1-newsreader-01.iinet.net.au...

Yes, if the application matters, use error-trapping in every sub and
function in your application.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Thelma Lubkin" <th****@alpha2.csd.uwm.edu> wrote in message
news:df**********@uwm.edu...

I use code extensively; I probably overuse it. But I''ve been using
error trapping very sparingly, and now I''ve been trapped by that.

A form that works for me on the system I''m using, apparently runs into
problems on the system where it will actually be used, and since I
used so little error-trapping it dies very ungracefully.

I will of course try to fix whatever is causing the error and add
error-trapping to the functions where the problem surfaces, but I
realize that I need to add error-trapping code with a more liberal
hand.

My question is, therefore, should error-trapping code bookend every sub
and function? If not, what criteria do I use to decide whether to add
it or not?
--thanks, thelma




这篇关于捕获代码时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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