Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
erik_seaberg
on July 17, 2019
|
parent
|
context
|
favorite
| on:
Declined Proposal: A built-in Go error check funct...
To be fair, reporting that cleanup also failed with a
different
error is inherently complicated, and so many people got the try-finally version wrong that Java finally added try-with-resources and Throwable#addSuppressed.
danielparks
on July 18, 2019
[–]
Definitely true. Mostly I just avoid using defer with Close, but I sometimes end up writing terrible stuff like:
defer func() { err2 := f.Close() if err == nil { err = err2 } }()
Not perfect, but better than nothing. I could use Wrapf to add information is err is already set. :-p
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: