top | item 42410687

(no title)

mlunar | 1 year ago

In Go you can do errorf("%w: %s", err, path) so that you get "file not found: foo/bar.json", while still being able to match on the wrapped error value with errors.Is(). The caller can do the same with this error and so on up the stack

discuss

order

fpoling|1 year ago

I dislike this style in Go. It adds a lot of noise to the source and essentially builds a stack trace manually. In Go 1.23 there is errors.Wrap() that adds the error stack automatically so maybe at some point Go will consider again adding some sugar for automatic error propagation.

lukax|1 year ago

Go errors in standard library does not support stack traces. errors.Wrap() only exists in github.com/pkg/errors package