diff --git a/CHANGELOG.md b/CHANGELOG.md index e46cf86..87d6cae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [5.3.3] - 2023-08-16 +### Fixed +- First error inconsistently wrapped with error and prefix instead of err then prefix in the chain. + ## [5.3.2] - 2023-08-16 ### Fixed - Link Error output missing error when prefix was blank. @@ -41,7 +45,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated deps. -[Unreleased]: https://github.com/go-playground/errors/compare/v5.3.2...HEAD +[Unreleased]: https://github.com/go-playground/errors/compare/v5.3.3...HEAD +[5.3.3]: https://github.com/go-playground/errors/compare/v5.3.2...v5.3.3 [5.3.2]: https://github.com/go-playground/errors/compare/v5.3.1...v5.3.2 [5.3.1]: https://github.com/go-playground/errors/compare/v5.3.0...v5.3.1 [5.3.0]: https://github.com/go-playground/errors/compare/v5.2.3...v5.3.0 diff --git a/README.md b/README.md index 6ea2e72..f5c0368 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Package errors ============ -![Project status](https://img.shields.io/badge/version-5.3.2-green.svg) +![Project status](https://img.shields.io/badge/version-5.3.3-green.svg) [![Build Status](https://travis-ci.org/go-playground/errors.svg?branch=master)](https://travis-ci.org/go-playground/errors) [![Go Report Card](https://goreportcard.com/badge/github.com/go-playground/errors)](https://goreportcard.com/report/github.com/go-playground/errors) [![GoDoc](https://godoc.org/github.com/go-playground/errors?status.svg)](https://pkg.go.dev/github.com/go-playground/errors/v5) diff --git a/chain.go b/chain.go index ff800ea..f6d6f8c 100644 --- a/chain.go +++ b/chain.go @@ -222,7 +222,7 @@ func (c Chain) Is(target error) bool { } target = innerErr[0].Err } - return stderrors.Is(c[0].Err, target) + return stderrors.Is(c[len(c)-1].Err, target) } // As finds the first error in the error chain that matches target, and if so, sets @@ -245,7 +245,7 @@ func (c Chain) As(target any) bool { if len(c) == 0 { return false } - return stderrors.As(c[0].Err, target) + return stderrors.As(c[len(c)-1].Err, target) } func defaultFormatFn(c Chain) string { diff --git a/errors.go b/errors.go index ce5c19b..201b501 100644 --- a/errors.go +++ b/errors.go @@ -1,7 +1,6 @@ package errors import ( - "errors" stderrors "errors" "fmt" "reflect" @@ -38,7 +37,7 @@ func RegisterErrorFormatFn(fn ErrorFormatFn) { // New creates an error with the provided text and automatically wraps it with line information. func New(s string) Chain { - return wrap(errors.New(s), "", 3) + return wrap(stderrors.New(s), "", 3) } // Newf creates an error with the provided text and automatically wraps it with line information.