Hacker News new | past | comments | ask | show | jobs | submit login

Here is an fictitious example of an error that was wrapped from deep in the internals of the net package all the way up to the HTTP handler serving the user. It was wrapped five times and clearly outlines what went wrong at each stage.

> failed loading config: unable to reach host example.com: tcp: dns lookup: timeout

https://pkg.go.dev/errors#Is and friends can be used to figure out what type/class of error exists in this chain so there is no loss of information either. It's more than just string concatenation. It's an actual tree of errors that also presents well for the logger.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: