TL;DR: The proposal looks good, except the handler chaining part, which adds a lot of magical complexity to cater to rare use cases. Chaining can always be added at a later stage without breaking backwards compatibility, if its lack is deemed unbearable.
As I see it, the biggest issues in current Go usage the proposal tackles are:
- Repeated sequences of
if err != nil {return nil, err}
littering Go code - Lack of proper context in propagated errors (see (1) above)
To fix these issues, I believe the proposed check
keyword with a single handler
per function are sufficient. Using stacks of handlers for proper cleanup is best left to defer
, which is already a familiar tool. Thus, handle
should only exist as a default "report more context in case of an error and return the error" mechanism. Where a single handler appears insufficient because the nature of error handling required changes throug