Exception handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution.
- Stackoverflow.com Wiki
When dealing with errors, handling them at the perimeter of your application isn't always sufficient. By the time the error bubbles up, you've often lost a lot of the context in which the error was thrown. As such, people will sometimes catch an error, record it locally in some way, and then rethrow it.
This blog post gives tips for error handling in asynchronous, Promise-based functions.
According to the NASA ‘Near Earth Object Program’ asteroid ‘101955 Bennu (1999 RQ36)’ has a Cumulative Impact Probability of 3.7e-04, i.e. there is a 1 in 2,700 (0.0370%) chance of Earth impact, but more reassuringly there is a 99.9630% chance the asteroid will miss the Earth completely!
Applications use exception handling logic to explicitly handle the exceptions when they happen. Exceptions can occur for a wide variety of reasons. From the infamous NullReferenceException to a database query timeout.
When you use the word Exception it always sounds scary, but exceptions in .NET are far from scary and are much more useful than the old days of returning error codes and error strings. There’s no excuse for your methods to provide return values which hide the details of why something went wrong.
Whilst this post is targeted towards Web API, it's not unique to Web API and can be applied to any framework running on the ASP.NET Core pipeline.