DEV Community

loading...

Discussion on: Custom exceptions with JS

Collapse
sqlrob profile image
Robert Myers

The way I've always heard, and continue to follow, exceptions are for exceptional conditions. They shouldn't be for logic flow.

In a good many of my projects (all languages), there's plenty of throws, but almost no catches at all, except maybe at or near the top level. In the case of errors, I want things to blow up. If the db goes down, there's not much I can do. If I have a bug that results in a throw, it's noisy and I have a nice stack trace right to it, fail early and noisy.