Hi all
I wanted to check something, I have sentry integrated and it is logging when issues occur, eg: NullException at line 123, however line 123 that it reports on is not the line that threw the exception.
How does one configure it to show exactly which line was the problem?
eg:
line 1: try{
line 2: // logic
…
line 30: } catch{}
If an error occurs anywhere between line 2 and 30, the log will report a fault at line 1, or sometimes a line number is given that isn’t even in the same method that was caught.
I’m also sure I saw somewhere in some marketing for sentry that the log could also display the line text itself in the log on sentry not just a line number eg:
“string customer_name = model.customer_name;”
Would be included in the log on sentry.
Am I missing some config somewhere to correctly show the line number of what threw the exception?
Thanks
How does one configure it to show exactly which line was the problem?
I don’t think it’s your configuration. It’s an issue with the exception reflection itself.
Here’s what’s up: If PDB files are not available for the DLL where the exception was thrown, some information will be lost or obfuscated. For instance; you get only one stack frame and you also get the ILOffset reported instead of the line number. This is true also for the “nonofficial” SharpRaven.Core client.
For .NET Core: If the exception is thrown from an outside DLL, and not the application code itself, then this will always be the case.
I’m also sure I saw somewhere in some marketing for sentry that the log could also display the line text itself in the log on sentry not just a line number […]
This depends on the client used to send the event (i.e. Raven), and the programming language itself (i.e. C#). It’s not an issue with Sentry, it’s perfectly capable of handling and storing the source-line.
I’m not sure how viable it is to extract the source-line from an exception (I haven’t tried yet). But what are you aiming to gain by this? Syntax-errors are non-existent in C# as it is a complied language, so apart from code-recognition, there isn’t much to gain here.