If your application is riddled with try-catch blocks, you might want to get familiair with Exception Filters. These are a type of middleware that you can hook into your request pipeline quite easily, which can give you a much more central and intuitive way of handling your errors.

Over the years I’ve seen many methods with error-handling similar to this:

The action is simple. We want to update the details of an Employee. Due to various rules, it might have a few different outcomes. Now we can handle these inside the method itself. …

Niek Kuijken

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store