Skip to content

Go2ErrorHandlingFeedback

DeedleFake edited this page Sep 21, 2018 · 185 revisions

Go 2 Error Handling Feedback

This page is meant to collect and organize feedback about the Go 2 error handling draft design.

Please post feedback on your blog, Medium, GitHub Gists, mailing lists, Google Docs, etc. And then please link it here.

Please help categorize the rest of the uncategorized proposals at the bottom.

In support

This includes supporting the existing chaining/stacking of handlers without changes.

Example code

Code changed to use the existing proposal.

Against

Critiques without counter-proposals

Counter-proposals

Error handling with normal functions

Labeled error handlers

Inlining

Just remove chaining/stacking

Use defer

try/catch/finally syntax

Other

Uncategorized

Please help categorize the rest of the proposals here.

Adding Your Feedback

Please format all entries as below.

  • Your Name, “Title”, month year

To make it easier to see new feedback, please add your new proposal to the top of the section it is placed in.

Quick Comments

  • DeedleFake: One of the issues with the syntax of check, as proposed, is that chaining method calls with error returns will look really, really bad. For example, check (check (check v.m1()).m2()).m3(). The common way around this in many languages is the use of ? as a postfix operator instead of prefix keyword, but this has other problems, including resulting in similar illegibility if there are nested function calls, such as in f1(f2(f3()?)?)?. So how's this for an alternate solution: When check is given a compound expression, such nested function calls or chained methods, it applies to all calls in the expression, not just the one it was specifically attached to. The previous two examples then become check v.m1().m2().m3() and check f1(f2(f3())), respectively. All other aspects of check remain the same, meaning that you could still use something like v, err := f1(check f2()) and whatnot.
    • DeedleFake: One potential awkwardness with this is the case of multiple returns being intended for use directly, such as with func f1(int, error); func f2() (int, error); check f1(f2()). It may be possible, however, for the application of check to be conditional on the usage of the types of each call, so it simply wouldn't affect the inner call to f2() in this case, the same as it not affecting a call to a function with no error return value. It would also be possible to get around this by manually calling f2() on a previous line, assigning the returns to values, and then passing those to f1().
Clone this wiki locally