Skip to content

Comment on What canceled my Go context?parent

Comments

> After a decade of writing Go I still don’t have a good rule of thumb for when I should wrap an error with more info or return it as-is.

When writing your tests:

1. Ensure all error cases are identifiable to the caller — i.e. using errors.Is/errors.AsType

2. Ensure that you are not leaking the errors from another package — you might change the underlying package later, so you don't want someone to come to depend on it

As long as those are satisfied, it doesn't matter how it is implemented.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.