All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
0.10.0 - 2024-09-09
- Expose all error's data when using in an unhandled panic. #16
0.9.0 - 2024-09-06
- Support for Go 1.22 and 1.23.
- Support for Go 1.16.
0.8.1 - 2023-12-04
- JSON marshal of value receiver errors. #15
0.8.0 - 2023-10-12
- Detect stack traces in errors made by
github.com/rotisserie/eris
package. GetMessage
toFormatter
to control how error messages are obtain from errors during formatting.
0.7.2 - 2023-09-21
- Deep compare stack traces when formatting.
0.7.1 - 2023-09-20
- Use mutex when initializing details to prevent race conditions.
- Access details during formatting only when they are needed.
0.7.0 - 2023-09-19
Prefix
function to construct a new error by prefixing an error with base errors.
0.6.0 - 2023-09-16
WithDetails
now accepts optional pairs of keys and values as initial details.Errorf
supports multiple%w
when used with Go 1.20 or newer.StackFormatter
which allows you to format stacks and marshal them to JSON.Formatter
which allows you to format errors (including ones not from this package) and marshal them to JSON.- Error formatting accepts multiple flags to control the output, including
#
flag to enable formatting of any details available on an error. It also accepts width to control indentation and precision to control if formatting recurses and/or uses error'sfmt.Formatter
implementation. - Support for Go 1.21.
StackTrace
type alias for better compatibility withgithub.com/pkg/errors
.Unjoin
function to find joined errors.UnmarshalJSON
to unmarshal JSON errors into placeholder errors which can then be formatted in the same way as other errors from this package.WithWrap
function to set an error as a cause of the base error.
- Formatting of errors has been changed so that
%+v
resembles the formatting ofgithub.com/pkg/errors
while additional formatting flags are necessary to obtain more verbose formatting previously done by this package (e.g.,-
for human-friendly messages to delimit parts of the text, ' ' to add extra newlines to separate parts of the text better). You can replace all%+v
in your code with% +-.3v
to obtain previous verbose formatting and% #+-.3v
if you want to include new support for formatting details. #5 #8 - Error formatting now by default uses
fmt.Formatter
implementation of an error only if the error does not implement interfaces used by this package (e.g.,stackTracer
ordetailer
). This is to assure consistent error formatting when possible. You can change this default through format precision. Details
now unwraps the error to find the first one providing details, only until an error with a cause or which wraps multiple errors.AllDetails
collect details only until an error with a cause or which wraps multiple errors.- JSON marshaling adds fields from error's details into JSON. #7
Wrap
andWrapf
returnnil
if provided error isnil
.
- Remove
StackFormat
andStackMarshalJSON
in favor ofStackFormatter
.
0.5.0 - 2023-06-06
StackFormat
to format the provided stack trace as text.StackMarshalJSON
marshals the provided stack trace as JSON.- Support wrapping multiple errors with
errors.Join
. #4
Wrap
behaves likeNew
andWrapf
likeErrorf
if provided error is nil instead of returningnil
. #2- Package is tested only on Go 1.16 and newer.
- Lines
stack trace (most recent call first):
andthe above error was caused by the following error:
changed to lower case.
0.4.1 - 2022-04-21
- Initialize details when calling
WithDetails
to prevent race conditions.
0.4.0 - 2022-04-20
- Errors returned by this package provide also optional details map accessible
through
detailer
interface. WithDetails
which wraps an error exposing access to (a potentially new layer of) details about the error.
0.3.0 - 2022-01-03
- Change license to Apache 2.0.
0.2.0 - 2021-12-01
errors.Cause
handles betterCause
which returnsnil
.- JSON marshaling of foreign errors uses
errors.Cause
.
0.1.0 - 2021-11-30
- First public release.