我正在寻找一种方法来检索当前异常,而不必将其作为变量传递。
假设下面的代码
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
}
在监视窗口中,我可以使用 $exception 来获取当前的异常。有等效的代码吗?
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)