错误检测 [英] error detection

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

问题描述

我正在编写程序中的错误处理并需要一些输入。


Dim errorsFound As Boolean = False

Dim respstr As String

尝试

respstr = proxy.validate(soapmesg)

Catch ex As Exception

errorLabel.Text = ex。消息

errorsFound = True

结束尝试

如果没有错误发现.....


我宁愿不使用boolean errorsFound。我不知道的是,如果在respstr = proxy.validate(soapmesg)中发生

异常,我可以依靠

respstr为空吗?如果是这样我会说如果不是respstr =""

I''m working on error handling in my program and need some input.

Dim errorsFound As Boolean = False
Dim respstr As String
Try
respstr = proxy.validate(soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
errorsFound = True
End Try
If Not errorsFound .....

I''d rather not use boolean errorsFound. What I don''t know is if an
exception occured in respstr=proxy.validate(soapmesg) can I count on
respstr being empty? If so I''ll just say If not respstr = ""

推荐答案

cj写道:
我'我在我的程序中处理错误处理并需要一些输入。

Dim errorsFound As Boolean = False
Dim respstr As String
尝试
respstr = proxy.validate (soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
errorsFound = True
结束尝试
如果不是errorFound .....
我宁愿不使用boolean errorsFound。我不知道的是,如果在respstr = proxy.validate(soapmesg)中发生了
异常,我可以依靠
respstr为空吗?如果是这样我会说如果不是respstr =""
I''m working on error handling in my program and need some input.

Dim errorsFound As Boolean = False
Dim respstr As String
Try
respstr = proxy.validate(soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
errorsFound = True
End Try
If Not errorsFound .....

I''d rather not use boolean errorsFound. What I don''t know is if an
exception occured in respstr=proxy.validate(soapmesg) can I count on
respstr being empty? If so I''ll just say If not respstr = ""




除非你在错误中写回或记录了什么

你不应指望respstr是什么。我会重置它任何

时间有错误。


尝试

respstr = proxy.validate(soapmesg)

Catch ex As Exception

errorLabel.Text = ex.Message

respstr = string.empty

结束尝试


如果出现错误,另一个想法就是保留功能。



Unless you wrote or have documenation to what returns during an error
you should not count on respstr being anything. I would reset it any
time there is an error.

Try
respstr = proxy.validate(soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
respstr = string.empty
End Try

Another thought would be to leave the funtion if there is an error.


Chris写道:
除非您在错误期间写回或记录了什么,否则您不应指望respstr成为任何东西。我会重置它任何时候出现错误。

尝试
respstr = proxy.validate(soapmesg)
抓住ex Exception
errorLabel。 Text = ex.Message
respstr = string.empty
结束尝试
Unless you wrote or have documenation to what returns during an error
you should not count on respstr being anything. I would reset it any
time there is an error.

Try
respstr = proxy.validate(soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
respstr = string.empty
End Try




或者在try块之外初始化respstr:


respstr = string.empty

尝试

respstr = proxy.validate(soapmesg)

Catch ex As Exception

errorLabel.Text = ex.Message

结束尝试


然后你可以使用它(因此测试它是否为空)尝试之外

阻止。



Or initialize respstr outside of the try block:

respstr = string.empty
Try
respstr = proxy.validate(soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
End Try

You could then use it (and therefore test if it is empty) outside of the try
block.


哦哦,我急忙做一个例子我忘了说Dim respstr As

String =""


抱歉


问题的关键是respstr = proxy.validate(soapmesg) )

如果生成异常就设置respstr到某个东西?


你表示它不会。我倾向于同意。但克里斯说这可能是b $ b。我不知道你们每个人的信仰是多么坚定。让's $

看看别人怎么说。并且无论如何都可以随意回复

.

Leon Mayne写道:
Oh Oh, in my haste to make an example I forgot to say Dim respstr As
String = ""

Sorry

The point to the question is is could respstr=proxy.validate(soapmesg)
set respstr to something if it generates an exception?

You''re indicating it would not. I tend to agree. But Chris said it
might. I don''t know how firm each of you are in your beliefs. Let''s
see what some others have to say. And by all means feel free to reply
again yourself.
Leon Mayne wrote:
Chris写道:
除非您在错误期间写回或记录了什么,否则您不应指望respstr成为任何东西。我会重置它任何时候出现错误。

尝试
respstr = proxy.validate(soapmesg)
抓住ex Exception
errorLabel。 Text = ex.Message
respstr = string.empty
结束尝试
Unless you wrote or have documenation to what returns during an error
you should not count on respstr being anything. I would reset it any
time there is an error.

Try
respstr = proxy.validate(soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
respstr = string.empty
End Try



或者在try块之外初始化respstr:

respstr = string.empty
尝试
respstr = proxy.validate(soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
结束尝试

然后你可以在try
块之外使用它(因此测试它是否为空)。



Or initialize respstr outside of the try block:

respstr = string.empty
Try
respstr = proxy.validate(soapmesg)
Catch ex As Exception
errorLabel.Text = ex.Message
End Try

You could then use it (and therefore test if it is empty) outside of the try
block.



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

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