Re:Go 1.11 Beta 1 is released
by sacado2 on Wednesday June 27, 2018 @05:12AM
(#17406771)
I actually rarely type that very snippet. In like 3/4 of the cases, I make the error more specific, like
the remainder being either the snippet you put above or more complex error management.
[ Parent
| on HN ]
Re:Go 1.11 Beta 1 is released
by erik_seaberg on Friday June 29, 2018 @04:53AM
(#17423282)
You can enrich err.Error(), but when you do you lose the type of the original error and any other fields it may have had. This is something the language can and should do more reliably (i.e., sugar could mutate err.Error() and prepend "MyStruct.myMethod failed: ", or better yet add a damn stack trace).