Comment

Comment by hbrn

Just because it's useful to wrap exceptions in 5% of the cases doesn't mean you should wrap the rest 95% just in case. YAGNI.

1. You don't know which exceptions will be raised in advance. Anything that involves IO can fail in a plethora of ways, and you don't even know which calls involve IO (e.g. a library might choose to cache something on disk).

2. Consumers of your code will not know how to deal with those exceptions.

3. Most of exceptions are unrecoverable (that's why they are called exceptions), the best course of action is to crash, which happens by default.

4. You debug those exceptions by looking at stack trace. Adding extra levels just to give a fancy meaningless name to an exception does not help.

5. The whole point of exceptions is to propagate. Parthenon essentially suggests converting exceptions into return values.

parent hbrn 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton