DEV Community

loading...

Discussion on: Errors Are Not Exceptions

Collapse
shalvah profile image
Shalvah • Edited

Still reading the article, but this kept bugging me, so I had to comment.😁

Errors are unrecoverable, Exceptions are routine.

Isn't this the other way around? I remember someone (I forget who) saying, "Exceptions should be reserved for exceptional circumstances." As in, if something that's routine happens, you shouldn't throw an exception. Reserve exceptions for situations that shouldn't happen.

I don't know if I'm all in on that. It's something I'm still mulling on. Just had to say it because it seems like you see it differently. Maybe it's just a nomenclature issue.😅

Collapse
shalvah profile image
Shalvah

Another thing is: I feel like we may be co-opting language terminology and constructs into our programming model, rather than the other way around. For instance, just because a language says "We don't have exceptions" doesn't mean that's true. If it has some error-handling mechanism that acts identically to exceptions, in most languages, then those are exceptions.

I think distinguishing between "error" and "exception" is a doomed task, because those are defined by the language. I often use them interchangeably. Maybe we should use language-agnostic terms like "failures" vs "errors", where:

  • failure = this operation failed for an anticipated reason
  • error = this operation failed for an unexpected reason

In summary: This shit is confusing. 😂