Exception.Message property considered harmful October 27, 2021 Author: Oren Eini, CEO RavenDB
Read the orginal blog post

Exception.Message property considered harmful

by Oren Eini, CEO RavenDB October 27, 2021

I just went over the following pull request, where I found this nugget:


I have an admittedly very firm views on the subject of error handling. The difference between good error handling and the merely mediocre can be ten times more lines of code, but also hundred times less troubleshooting in production.

And a flat out rule that I have is that whenever you have a usage of the Exception.Message property, that means that you are discarding valuable information aside. This is a pretty horrible thing to do.

You should never use the Message property, always use the ToString(), so you’ll get the full details. Yes, that is relevant even if you are showing to the user. Because if you are showing an exception message to the user, you have let it bubbled up all the way, so you might as well give full details.

Share your thoughts or ask us a question