For example, in one place...
//---------------a
try
{
// some network call
}
catch(WebException we)
{
throw new MyCustomException("some message ....", we);
}
...and in another place...
//--------------b
try
{
// invoke code above
}
catch(MyCustomException we)
{
Debug.Writeline(we.stacktrace); // <----------------
}
The stacktrace I print, it only start from a to b, it doesnt include the inner stacktrace from the WebException.
How can I print all the stacktrace???
I usually use the .ToString() method on exceptions to present the full exception information (including the inner stack trace) in text:
Sample output:
Use a function like this:
Then you can call it like this:
If you pass your exception to the following function, it will give you all methods and details which are reasons of the exception.
Result:
File: c:\MyProject\Program.cs, Method:MyFunction, LineNumber: 29 -->
File: c:\MyProject\Program.cs, Method:Main, LineNumber: 16 -->