if err != nil {
return err

This can be the proper thing to do in some cases. But in many cases it is
really just the lazy thing to do when instead a different error with a
message appropriate for the given context can be returned. Enforcing this
pattern with a simplified syntax promotes unhelpful error messages.
On Friday, April 5, 2013 12:58:13 AM UTC-7, Volker Dobler wrote:

Am Freitag, 5. April 2013 09:31:11 UTC+2 schrieb Craig Mason-Jones:
I am interested in error-related changes. Frequently I want to check for
an error, and pass it 'up' if it occurs:

_, err := someFn()
if nil!=err { return err }

I've tidied that up a little to

if _,err :=someFn(); nil!=err {
return err

This almost becomes boilerplate, and causes a lot of tedious repetition
and duplication. If I change my function return signature, I have to
duplicate this at each point.

That is exactly the way to go. It isn't considered "boilerplate" but
"error handling".

I would like to have something like this:
This won't happen the next years. Anyway: You will get used to what you
think of as "boilerplate".

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 19 | next ›
Discussion Overview
groupgolang-nuts @
postedApr 5, '13 at 7:31a
activeApr 12, '13 at 6:37a



site design / logo © 2021 Grokbase