Catching Exceptions with Exception Handling
We always try to make our code as stable as possible when building web applications, but there are times when we can’t catch everything. This is why exceptions are considered a foundational part of development. Exception handling is essential for preventing web applications from crashing and displaying an ugly error message on a page. It’s tempting to wrap everything with try
/catch
or try
/finally
statements and move on. This should be avoided. Coding with try
/catch
/finally
statements in an application should be the exception to the rule.
The common coding standards in this chapter are meant to remove those types of scenarios and provide a better developer experience.
In this chapter, we’ll examine what exception handling means to developers and when to use it, along with where to handle global exceptions and examine performance considerations. Once we understand the basics of exception handling, the last section...