Hacker News new | ask | show | jobs
by drivebyhooting 3 hours ago
I think my opinion will be even more maligned: I like Java-style checked exceptions. It forces awareness of the error and a clean way to propagate it.
2 comments

People advocate for Go's error handling because it forces you to deal with errors.

But in the cases I do want to catch a specific error, the signature only tells me that a function returns an error, not which type. So I do feel that returning (int, error) is strictly worse than Java's checked exceptions if you care about errors.

The thing that most annoys me in Java in that area is when a dependency throws an unchecked error that wasn’t even documented.

Thanks so much for that! Now I have no choice but to be reactive when something fails…