DEV Community

Discussion on: Exceptions Considered Harmful

Collapse
 
ashleyjsheridan profile image
Ashley Sheridan

I was in agreement with you about handling uncertainty properly, and exceptions allow you to do exactly that.

The fact is, we will undoubtedly need to work with 3rd party libraries et al in our code. If the language supports exceptions, then we will need to handle them. It makes sense to use them if we need to handle them at some point anyway.

Plenty of incredibly popular and powerful languages use exceptions to handle errors, that's their solution to handling the error problem. If Go & Rust don't, that's fine, it doesn't make them bad languages or mean that exceptions are bad or to be avoided.

Thread Thread
 
pianomanfrazier profile image
Ryan Frazier

My usual pattern with 3rd party libraries is to catch the exception immediately around the function call then convert it to a Result. Some functional libraries even have a helper function for this. See Purify's encase function gigobyte.github.io/purify/adts/Eit...