go-errors / errors

errors with stacktraces for go
https://godoc.org/github.com/go-errors/errors
MIT License
935 stars 93 forks source link

ErrorStack() adds `*fmt.wrapError` prefix #47

Closed ghostsquad closed 1 year ago

ghostsquad commented 1 year ago

I'm seeing this weird *fmt.wrapError prefixed to the output. https://go.dev/play/p/ThypuXRoewr

Switching to this gets rid of that prefix: fmt.Printf("%+v", err)

https://go.dev/play/p/hJtbPlS-zEh

ConradIrwin commented 1 year ago

:wave: this is expected, .ErrorStack() outputs the concrete type of the error too (https://github.com/go-errors/errors/blob/v1.5.1/error.go#L181).

This was probably an error in taste on my part (before writing this I was mostly using ruby/python/js all of which output the error type by default; but I've since learned that go programs typically do not).

It's probably about time to figure out a v2 that works better with the "new" standard library error support (like %w and Wrap) which didn't exist at the time this package was created. Very open to what that API should look like – as it seems like the main remaining piece that the stdlib does not support is attaching the backtrace, maybe it's a simpler API for just that.

ghostsquad commented 1 year ago

If you want a partner in V2, I'd love to help. 😊