Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor errdefs with an API more similar to the standard library #14

Closed
wants to merge 1 commit into from

Conversation

jsternberg
Copy link

This updates errdefs to have an API similar to the standard library. The New method is the equivalent of fmt.Errorf and Join is the equivalent of errors.Join.

These methods also support the proper output of stack traces by ensuring the proper handling of the formatting for collapsible errors.

Similarly, the stack package has been updated to remove the context-based helper and instead directly expose the function that creates the stack error. The stack error is also renamed to Error and exposed rather than left unexported.

The stack package can be used to directly create errors with stacks when one isn't present. It is also possible to add multiple stacks to a single error through errdefs.Join and errdefs.ErrStack to manually create a stack error.

This updates errdefs to have an API similar to the standard library. The
`New` method is the equivalent of `fmt.Errorf` and `Join` is the
equivalent of `errors.Join`.

These methods also support the proper output of stack traces by ensuring
the proper handling of the formatting for collapsible errors.

Similarly, the `stack` package has been updated to remove the
context-based helper and instead directly expose the function that
creates the stack error. The stack error is also renamed to `Error` and
exposed rather than left unexported.

The `stack` package can be used to directly create errors with stacks
when one isn't present. It is also possible to add multiple stacks to a
single error through `errdefs.Join` and `errdefs.ErrStack` to manually
create a stack error.

Signed-off-by: Jonathan A. Sternberg <[email protected]>
@jsternberg
Copy link
Author

I no longer think this API is a good fit for this library so I will be closing this issue.

@jsternberg jsternberg closed this Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant