mshwf
mshwf

Reputation: 7449

How to read the StackTrace?

I hope this question can survive the rules of SO, as I searched a lot, didn't find a documentation on it, and sometimes ignored it, but that drove me to not understanding the problem nor the solution. the StackeTrace of the Exceptoion has its own way of describing the problem, yes in a human-friendly language but with symbols and code that I don't know about or where it comes from, this is one of these that I ignored because I don't understand what it says, but I can't solve the problem:

at System.Net.Http.HttpClientHandler+d__63.MoveNext () [0x004ab] in <35658e59c86d40bdbb2ef0bb34b4f0c7>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in <35658e59c86d40bdbb2ef0bb34b4f0c7>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at PSProject.Helpers.Utility+d__15.MoveNext () [0x00136] in D:\PSProject\PSProject\PSProject\PSProject\Helpers\Utility.cs:212

The exception is thrown when I try to to Get data through a webservice via HttpClient.PostAsync from a Wi-Fi network, not mobile data (this is a Xamarin app). What can I understand from that trace? For example:

  1. What is the HttpClientHandler and where it is located:

in <35658e59c86d40bdbb2ef0bb34b4f0c7>

  1. This was mentioned two times:

End of stack trace from previous location where exception was thrown

Is this an internal code for HttpClient class?

How to get know the most of the StackTrace to understand the exception?

Upvotes: 4

Views: 11768

Answers (1)

Mohammed Noureldin
Mohammed Noureldin

Reputation: 16806

Stack tracer is complicated because you are using async/await. You do not need most of the information from the above trace. Mostly you are ok to ignore the error codes and anything related to awaiter.

Find the first position where the awaiter is not mentioned, and mostly you are going to find a line number over there. It is mostly the position which threw the Exception you are investigating.

In your example it is this line:

PSProject.Helpers.Utility+d__15.MoveNext () [0x00136] in D:\PSProject\PSProject\PSProject\PSProject\Helpers\Utility.cs:212

It is the first position where the awaiter is not mentioned. The line number in Utility.cs file which threw the Exception is 212.

Upvotes: 2

Related Questions