如何获得,而不必通过该变量的当前异常? [英] How to get the current exception without having passing the variable?
本文介绍了如何获得,而不必通过该变量的当前异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要寻找一个方法来检索当前异常,而不必把它作为一个变量。
I am looking for a way to retrieve the current exception without having to pass it as a variable.
假设下面的代码
public void MakeItFail()
{
try
{
throw new FailException();
}
catch // Yes I'm aware that this shouldn't be done, but I don't want to go through all the code base and change it
{
ShowMessage("An error occured");
}
}
public void ShowMessage(string message)
{
// How can I retrieve the exception here
}
在监视窗口,我可以用$例外来获得当前异常。有是一个代码等同?
In the watch window, I can use $exception to get the current exception. Is there is a code equivalent?
推荐答案
没有,没有。
您需要使用的参数。
这篇关于如何获得,而不必通过该变量的当前异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文