我似乎错过了我的堆栈跟踪中的一些信息,这是我得到的:
at Foo.Bar(DataTable table) in D:\Foo\Bar\authoring\App_Code\FooBar.vb:line 87
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪信息的其余部分在哪里?
编辑:
Web.Config中的自定义错误设置为关闭,我正在处理它被捕获的错误:
Catch ex As Exception
Respose.Write(ex.StackTrace)
End Try
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪仍然被截断.
确保web.config中的customErrors设置为"RemoteOnly"或"Off"以禁用友好错误.
或者可能堆栈跟踪重置?(虽然如果是这种情况你仍然应该看到一些东西)
将重置您的堆栈跟踪.
catch(Exception ex)
{
throw ex;
}
Run Code Online (Sandbox Code Playgroud)
不会重置堆栈跟踪.
catch(Exception ex)
{
throw;
}
Run Code Online (Sandbox Code Playgroud)
编辑:
ex.StackTrace获取当前堆栈.堆栈跟踪从抛出异常的地方开始(发生错误),并在捕获异常的当前堆栈帧结束.所以它正在反转调用堆栈.因为你一旦发现堆栈跟踪就写出来,它就没有机会进一步向上调用堆栈.
根据您的工作,您可以尝试一些事情.
//To just see the stackTrace
Catch ex As Exception
Throw
End Try
Run Code Online (Sandbox Code Playgroud)
Environment.StackTrace - 获取当前堆栈跟踪信息
//If you are trying to log the stacktrace
Catch ex As Exception
Respose.Write(Environment.StackTrace)
Respose.Write(ex.StackTrace)
End Try
//If is hiding then try - hiding as in throw ex vs just throw
Catch ex As Exception
//careful innerException can be null
//so need to check before using it
Respose.Write(ex.InnerException)
End Try
Run Code Online (Sandbox Code Playgroud)
其中一种方法应该适合你.
| 归档时间: |
|
| 查看次数: |
874 次 |
| 最近记录: |