File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -66,4 +66,13 @@ everyone can benefit.
6666This package is licensed under the MIT license, see LICENSE.MIT for details.
6767
6868## Changelog
69- * v1.1.0 updated to use go1.13's standard-library errors.Is method instead of == in errors.Is
69+ * v1.1.0 updated to use go1.13's standard-library errors.Is method instead of == in errors.Is
70+ * v1.2.0 added ` errors.As ` from the standard library.
71+ * v1.3.0 * BREAKING* updated error methods to return ` error ` instead of ` *Error ` .
72+ > Code that needs access to the underlying ` *Error ` can use the new errors.AsError(e)
73+ > ```
74+ > // before
75+ > errors.New(err).ErrorStack()
76+ > // after
77+ >. errors.AsError(errors.Wrap(err)).ErrorStack()
78+ > ```
Original file line number Diff line number Diff line change @@ -207,3 +207,10 @@ func (err *Error) TypeName() string {
207207func (err * Error ) Unwrap () error {
208208 return err .Err
209209}
210+
211+ // AsError converts e to an *errors.Error.
212+ // If e does not already have a stacktrace attached, the current stack
213+ // will be added.
214+ func AsError (e error ) * Error {
215+ return Wrap (e , 1 ).(* Error )
216+ }
You can’t perform that action at this time.
0 commit comments