可能尝试...捕捉...结束尝试 [英] Possible TRY...CATCH...END TRY

查看:74
本文介绍了可能尝试...捕捉...结束尝试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!


我想我发现.NET Framwork可能有所改进了

尝试...捕捉...结束尝试声明。我想大多数开发人员可能还会发现他们在.NET开发过程中的某些时候发现了b $ b,但由于他们的工作量,他们继续忽略这个问题。


这个词是重试。


考虑以下......


尝试


''......东西


抓住e作为FileNotFoundException


''更正错误然后

重试


抓住e2作为DirectoryNotFoundException


''更正错误然后

ReTry


抓住e3作为DriveNotFoundException


''更正错误然后

重试


Catch''<<捕捉''未知''错误


''记录错误


最后


结束尝试


我们.NET程序员可以在任何Catch

块中使用关键字RETRY来重新执行Try块中的代码。如果抛出另一个例外

,我们可以在许多Catch块之一中评估该异常,直到

达到''unkown''异常。 br />

因此,我建议将一个新的关键字ReTry作为一项改进纳入.NET

Framework 2中。


随意反馈这个想法...


-

Nay Myo Aung

首席视觉软件架构师

MCP MCSD MCDBA


电邮:owN0SPAMner @ naymyoauN0SPAMng.name [删除NOSPAM s]

主页: http://hyperdisc.unitec.ac.nz/postgrad/aungn01/

Hi All!

I think I discovered a possible improvement on .NET Framwork''s
TRY...CATCH...END TRY statement. I guess most developers might also have
been discovered that at some point in their .NET development process but
continued to ignore the problem due to their workloads.

The word is RETRY.

Consider the following...

Try

''...something

Catch e as FileNotFoundException

''correct the error and then
ReTry

Catch e2 as DirectoryNotFoundException

''correct the error and then
ReTry

Catch e3 as DriveNotFoundException

''correct the error and then
ReTry

Catch ''<< catch ''unknown'' error

''log the error

Finally

End Try

We .NET programmers could use the keyword RETRY in the any of the Catch
block to re-execute the code in Try block. If there''s another exception
thrown, we can evaulate that exception in one of the many Catch blocks until
it reached to the ''unkown'' exception.

So, I propose that a new keyword ReTry should be incorporated in the .NET
Framework 2 as an improvement.

Feel free to feedback on the idea...

--
Nay Myo Aung
Chief Visual Software Architect
MCP MCSD MCDBA

Email: owN0SPAMner @naymyoauN0SPAMng.name [remove NOSPAM s]
Homepage: http://hyperdisc.unitec.ac.nz/postgrad/aungn01/

推荐答案

不会是调用者解决问题的责任和

重新调用方法和不将所有功能分组到一个类中,即

封装某些数据?方法?


Ollie Riches


" Nay Myo Aung" < owNOspaMnerATnaymyoauNOspaMng.name>在消息中写道

news:ui ************** @ TK2MSFTNGP14.phx.gbl ...
wouldn''t it be the RESPONIBILITY of the caller to sort out the problem and
re-call the method and not group all functionality into one class i.e
encapsulate away certain data\methods ?

Ollie Riches

"Nay Myo Aung" <owNOspaMnerATnaymyoauNOspaMng.name> wrote in message
news:ui**************@TK2MSFTNGP14.phx.gbl...
大家好!

我想我发现了.NET Framwork的可能改进了
TRY ... CATCH ... END TRY声明。我想大多数开发人员也可能已经发现他们在.NET开发过程中的某些时候因为他们的工作负载而继续忽略这个问题。

这个词是RETRY 。

请考虑以下内容...

尝试

''......一些东西

抓住e作为FileNotFoundException

''更正错误,然后重新尝试

抓住e2作为DirectoryNotFoundException

''更正错误然后
重试

将e3作为DriveNotFoundException捕获

''更正错误然后
重新尝试

Catch''<<抓住''未知''错误
''记录错误

最后

结束尝试

我们.NET程序员可以在任何Catch
块中使用关键字RETRY来重新执行Try块中的代码。如果抛出另一个异常,我们可以在许多Catch块
之一中调整该异常,直到它达到未知异常。

所以,我建议将一个新的关键字ReTry作为一项改进纳入.NET
Framework 2.

随意对这个想法进行反馈......
-
Nay Myo Aung
首席视觉软件架构师
MCP MCSD MCDBA

电子邮件:owN0SPAMner @ naymyoauN0SPAMng.name [删除NOSPAM s]
主页: http://hyperdisc.unitec.ac.nz/postgrad/aungn01/
Hi All!

I think I discovered a possible improvement on .NET Framwork''s
TRY...CATCH...END TRY statement. I guess most developers might also have
been discovered that at some point in their .NET development process but
continued to ignore the problem due to their workloads.

The word is RETRY.

Consider the following...

Try

''...something

Catch e as FileNotFoundException

''correct the error and then
ReTry

Catch e2 as DirectoryNotFoundException

''correct the error and then
ReTry

Catch e3 as DriveNotFoundException

''correct the error and then
ReTry

Catch ''<< catch ''unknown'' error

''log the error

Finally

End Try

We .NET programmers could use the keyword RETRY in the any of the Catch
block to re-execute the code in Try block. If there''s another exception
thrown, we can evaulate that exception in one of the many Catch blocks until it reached to the ''unkown'' exception.

So, I propose that a new keyword ReTry should be incorporated in the .NET
Framework 2 as an improvement.

Feel free to feedback on the idea...

--
Nay Myo Aung
Chief Visual Software Architect
MCP MCSD MCDBA

Email: owN0SPAMner @naymyoauN0SPAMng.name [remove NOSPAM s]
Homepage: http://hyperdisc.unitec.ac.nz/postgrad/aungn01/





这是一个好主意!!


我们的VB程序员总是有On Error Goto< label>在哪里我们可以尝试

来修复错误并返回到块的开头。虽然我们仍然可以在.Net中执行此操作但我不想在尝试使用框架错误处理时使用

尝试...抓住...结束尝试。这个想法提供了一些非常好的处理异常的灵活性。我很惊讶他们在他们的.Net简报中没有提到这样的事情。


如果你正在听MS,请考虑这个。


Robby

Nay Myo Aung < owNOspaMnerATnaymyoauNOspaMng.name>在消息中写道

news:ui ************** @ TK2MSFTNGP14.phx.gbl ...

This is a great idea!!

We VB programmers have always had On Error Goto <label> where we could try
to fix the error and go back to the start of the block. While we can still
do this in .Net I prefer not to as I try to use the framework error handling
of Try ... Catch ... End Try. This idea offers some really great
flexibility for handling exceptions. I am surprised that they have not
mentioned anything like this in their .Net briefs.

If your listening MS, please consider this.

Robby
"Nay Myo Aung" <owNOspaMnerATnaymyoauNOspaMng.name> wrote in message
news:ui**************@TK2MSFTNGP14.phx.gbl...
大家好!

我想我发现了.NET Framwork的可能改进了
TRY ... CATCH ... END TRY声明。我想大多数开发人员也可能已经发现他们在.NET开发过程中的某些时候因为他们的工作负载而继续忽略这个问题。

这个词是RETRY 。

请考虑以下内容...

尝试

''......一些东西

抓住e作为FileNotFoundException

''更正错误,然后重新尝试

抓住e2作为DirectoryNotFoundException

''更正错误然后
重试

将e3作为DriveNotFoundException捕获

''更正错误然后
重新尝试

Catch''<<抓住''未知''错误
''记录错误

最后

结束尝试

我们.NET程序员可以在任何Catch
块中使用关键字RETRY来重新执行Try块中的代码。如果抛出另一个异常,我们可以在其中一个Catch块中评估该异常,直到达到未知异常为止。

所以,我建议将一个新的关键字ReTry作为一项改进纳入.NET
Framework 2.

随意对这个想法进行反馈......
-
Nay Myo Aung
首席视觉软件架构师
MCP MCSD MCDBA

电子邮件:owN0SPAMner @ naymyoauN0SPAMng.name [删除NOSPAM s]
主页: http://hyperdisc.unitec.ac.nz/postgrad/aungn01/



2004年12月3日星期五22:36:16 +1300,Nay Myo Aung写道:
On Fri, 3 Dec 2004 22:36:16 +1300, Nay Myo Aung wrote:
我们.NET程序员可以在任何Catch
块中使用关键字RETRY来重新执行Try块中的代码。如果抛出另一个异常,我们可以在许多Catch块之一中评估该异常,直到它达到''unkown''例外。

所以,我建议将一个新的关键字ReTry作为一种改进纳入.NET
Framework 2.
We .NET programmers could use the keyword RETRY in the any of the Catch
block to re-execute the code in Try block. If there''s another exception
thrown, we can evaulate that exception in one of the many Catch blocks until
it reached to the ''unkown'' exception.

So, I propose that a new keyword ReTry should be incorporated in the .NET
Framework 2 as an improvement.




当我第一眼看到我的眼球时看到你的想法是,它会很容易进入无限循环。一次又一次地重试

没有办法阻止这个。所以你需要在每个

中添加一个计数器来检查这个块是否无法执行。

相当混乱,不是吗?



The first thing that catched my eye when i saw your idea is that it would
be dead easy to enter an endless loop with this. Retry again and again
without any way to stop this. So you would need to add a counter in each of
your catch block to check if this block is not being executed endlessly.
Quite messy, isn''t it?


这篇关于可能尝试...捕捉...结束尝试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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