Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

PR Review: Is Your Error Handling Required?

DZone's Guide to

PR Review: Is Your Error Handling Required?

In this article, we go into a really quick look at error handling requirements, and why error handling must, like all code, be readable and justify itself.

Free Resource

Learn how error monitoring with Sentry closes the gap between the product team and your customers. With Sentry, you can focus on what you do best: building and scaling software that makes your users’ lives better.

While reviewing a PR, I run into what seemed like a strange thing. Take a look at this change:

image

This came with its own exception class and left me pretty confused. Why would I want to have something like that?

Here we have some error handling code that doesn’t seem to add any additional value. Everything in the error here can be deducted from the details of the exception that will be thrown if we did nothing.

The fact that we throw a specialized exception might be meaningful, but looking at the code, this isn’t actually used for anything.

Like all code, error handling needs to justify itself, and this one doesn’t pass the bar.

What’s the best way to boost the efficiency of your product team and ship with confidence? Check out this ebook to learn how Sentry's real-time error monitoring helps developers stay in their workflow to fix bugs before the user even knows there’s a problem.

Topics:
performance

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}