News for hackers. Stuff that matters.
Re:Declined Proposal: A built-in Go error check function, “try” by xienze on Tuesday July 16, 2019 @09:34PM (#20455631)
> Your 'happy path' must be surrounded by try blocks.

Not if you're doing it right, which means bubbling up (read: adding the exceptions to the "throws" clause) exceptions that you can't handle _then and there_. You leave the "real" exception handling to the code that's closest to the end user and can actually handle the error in a meaningful way.

For example, in this pattern when you implement the business logic in a REST service, generally there's no catching at all, instead the exceptions are declared as rethrown and way up the stack you would have a global catch all that serializes the errors into JSON and sends them to the user. Simple. In Go you're forced to do "if err{}" checks everywhere, particularly in your endpoint's business logic. It's actually _way less_ verbose and burdensome in Java if you do exceptions the right way.

There are no comments on this comment yet.