Posts

Showing posts with the label exception

.NET Global Exception Handling: 3 Techniques Beyond Try/Catch Blocks

Image
  Exceptions are a big part of any software solution. They happen sometimes because something went wrong like out of memory exceptions and sometimes, they happen because of the domain or the business such as validation exceptions. Either way it is something that must be planned ahead in any system design. And by planning I definitely don't mean sprinkling try/catch blocks all over your code. In this post I will explain three different techniques that will help you to globally handle exceptions and turn the messy response that exceptions return by default to a much organized and concise response. However, note that this does not mean that you should not stop using try/catch blocks if you need them for specific exception handling for specific cases. Our main focus is to manage to run some sort of logic that runs each time an exception occurs so that it prevents the default behavior and instead logs the full exception stack trace and only returns concise readable information for t...