logoalt Hacker News

sieve • today at 8:28 PM • 1 reply • view on HN

It might throw one. There is a difference between documenting what exceptions can be thrown and forcing every consumer to handle them.


Replies

spullara • today at 9:10 PM

returning a non-success you either handle it or pass it up the chain, potentially with not a lot of information about what originally caused it. with an exception you can retain the full information about what happened by either rethrowing it, throwing your own exception with it embedded as the cause or declaring that you don't handle it by saying you can throw it.

➕ show 1 reply