-
Notifications
You must be signed in to change notification settings - Fork 700
Consider StackTrace() []uintptr #79
Comments
Id love to do that, that was how it worked previously, but if the type is On Fri, 5 Aug 2016, 03:44 Jack Lindamood notifications@github.com wrote:
|
Why can't the error type have a |
Maybe it can change, I haven't looked closely. It depends if people want to On Fri, Aug 5, 2016 at 1:37 PM, Jack Lindamood notifications@github.com
|
Can't you make
|
I think I see what you mean now. I don't think it's too much to, if someone wants to format the stack only, to get it out as an []uintptr and call some string formatter on that. There are probably many ways someone may want to format a []uintptr. Maybe errors.Stack() is one way. |
Maybe I'm missing something but... why not both? Is there reason why the package couldn't support both I'd like to add support to raven-go, Sentry's library for capturing and reporting errors in Go programs, but accessing the stack trace from pkg/errors is also a hang-up for me. @davecheney If you're open to this, I can easily submit a PR. |
Was there ever a decision made about this? I'm in the same camp as cep21 and mark-adams, I think it would be valuable to have a universal API, and if you wanna keep the formatting methods, keep the current API as well (what mark-adams suggested). |
Hi,
I am trying to write a library to interoperate with wrapped errors.
There are many error wrapping libraries, but I can only get the StackTrace() of this one by importing this one. This creates problems trying to write library agnostic code.
With
Cause() error
, I can simulate an error exposing this interface inside my library, meaning I can interoperate with pkg/errors without needing to import it, as well as define an API that other libraries can implement without forcing them into pkg/errors API.With
StackTrace() StackTrace
I am forced to tell people wanting to work with my library to import errors, just for the StackTrace object, just to wrap their own stack trace with it.This is a general problem with APIs that don't use Go's core types as parameters. Since a stack trace is just an array of pointers, if the implementation was
StackTrace() []uintptr
, then other error wrapping libraries could standardize to this and we could all interoperate.I would also say that pretty printing a stack trace is behavior reasonably independent of wrapping errors itself. By returning the stack trace raw, you allow libraries to choose how it should be pretty printed: with maybe errors package providing a default implementation like it does now.
The text was updated successfully, but these errors were encountered: