IssueRaiser

NullReferenceException - Completely devoid of details

I don't know if this necessarily the right place for this, but the payoff is big enough to warrant a possible failed attempt. NullReferenceExceptions are the most common exceptions your average developer is going to encounter, and yet the only information that is included in the exception is the message that _something_ was null and you may or may not get a line number in the stacktrace. Take the following example: ``` _orderService.CreateOrder(items.ToList(), customer.CustomerId); ``` If I get a NullReferenceException on this line, there are three different objects that could have been null and caused the error (_orderService, items and customer). Knowing that it was specifically customer that was null would be incredibly helpful. Extending this concept further, having a small dump of all locally scoped variables when the exception was thrown would be incredibly useful, but I'll go with baby steps and just settle for knowing which variable/expression was the root cause of the null reference exception.

Posted by vongillern on Feb 3, 2015, 7:30 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.8,000 issues0 comments

github (Software)

NullReferenceException - Completely devoid of details

vongillernFeb 3, 2015, 7:30 PM

I don't know if this necessarily the right place for this, but the payoff is big enough to warrant a possible failed attempt. NullReferenceExceptions are the most common exceptions your average developer is going to encounter, and yet the only information that is included in the exception is the message that _something_ was null and you may or may not get a line number in the stacktrace. Take the following example: ``` _orderService.CreateOrder(items.ToList(), customer.CustomerId); ``` If I get a NullReferenceException on this line, there are three different objects that could have been null and caused the error (_orderService, items and customer). Knowing that it was specifically customer that was null would be incredibly helpful. Extending this concept further, having a small dump of all locally scoped variables when the exception was thrown would be incredibly useful, but I'll go with baby steps and just settle for knowing which variable/expression was the root cause of the null reference exception.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue