top | item 29164338

(no title)

dullgiulio | 4 years ago

Please no. I am still fighting the battle of adding contextual information to the error using fmt.Errorf.

I am tired of seeing

SocketException: hostname.com

as full error message.

discuss

order

AYBABTME|4 years ago

This, errors that are bubbled up should have some context added to them. Otherwise every error ends up being totally meaningless.

stouset|4 years ago

I repeatedly fail to understand why golang proponents insist on flogging themselves into becoming human stacktrace authors. This is a solved problem the computer can do better than you, automatically, on your behalf.

Certainly any shortcut syntax should not prevent you from adding human-curated context to your errors. But the current situation comes at an enormous cost, and I truly think there's a bit of Stockholm Syndrome going on here.

ladberg|4 years ago

I don't see how those are mutually exclusive. You could do something like:

  x, err := f(); if err != nil return fmt.Errorf("More context -> %s", err)
(I'm not attached to that specific syntax, it's just an example of a hypothetical one-liner)