在下一个方法中测试异常 [英] Test for Exception in next Method
本文介绍了在下一个方法中测试异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Method2中是否可以测试Method1中是否存在异常?
(彼此调用:Method1-> Method2)
只是知道是否有一个?
Is there a Way to test in a Method2 if there was a Exception in Method1?
(Called after each other: Method1 --> Method2)
Just to know if there was one?
推荐答案
测试任何异常情况是对该技术的大滥用.放开异常.
该怎么办?请在我过去的答案中找到一些建议:
我如何制作滚动条到达底部时将停止的循环 [当我运行应用程序时,异常是捕获了如何处理? [ throw. .then ... rethrowing [ ^ ].
-SA
Testing anything for exceptions is a big abuse of the technology. Let exceptions go.
What to do? Please find some recommendations in my past answers:
How do i make a loop that will stop when a scrollbar reaches the bottom[^],
When i run an application an exception is caught how to handle this?[^],
throw . .then ... rethrowing[^].
—SA
以防万一您在Method2中捕获到异常并在处理后将其扔回.
这样的东西
In case you catch the exception in Method2 and after processing throw it back.
Something like this,
sub method1()
{
try
{
method2();
}
catch(exception ex)
{
...
}
}
sub method2()
{
try
{
...
}
catch(exception ex)
{
...
throw ex;
}
}
您始终可以通过代码查看stacktrace.有关更多信息,请参见此处 [
You can always look at the stacktrace via code. For more information, see here[^].
这篇关于在下一个方法中测试异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文