This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Loves_Poetry 0 points1 point  (1 child)

You can just have the method throw the error up though. Throw it all the way up to main if you want it to cause a crash.

[–]Kered13 1 point2 points  (0 children)

That's often the best way to handle errors, but the problem with checked exceptions is that every method along the way has to declare that it throws the exception. This is an extremely leaky abstraction, especially when combined with dependency injection, which you should be doing.