DEV Community

Discussion on: On useless try-catches, being overly defensive, I/O boundaries and variable scope

Collapse
 
alainvanhout profile image
Alain Van Hout

As an alternate conceptual approach, you could say that everything inside the try block is the success path, while everything inside the catch block is the failure path.

Collapse
 
rikurouvila profile image
Riku Rouvila

Conceptually I like that a lot. If we'd have a way of defining thrown exceptions like Java's throws syntax, having the whole happy path inside the try block would feel a lot more comfortable.

Collapse
 
alainvanhout profile image
Alain Van Hout

Yes indeed. It's in fact from my own Java experience that I've come to use the approach 😄.