Skip to content

feat: add Unwrap() []error to ParseError for errors.Is/As support#51

Open
Yanhu007 wants to merge 1 commit intotemoto:masterfrom
Yanhu007:fix/parse-error-unwrap
Open

feat: add Unwrap() []error to ParseError for errors.Is/As support#51
Yanhu007 wants to merge 1 commit intotemoto:masterfrom
Yanhu007:fix/parse-error-unwrap

Conversation

@Yanhu007
Copy link
Copy Markdown

Fixes #47

Problem

ParseError wraps multiple errors in its Errs field but does not implement the Unwrap() []error interface (Go 1.20+). This means errors.Is and errors.As cannot inspect the underlying errors.

Fix

Add the Unwrap method:

func (e ParseError) Unwrap() []error {
    return e.Errs
}

Testing

All existing tests pass.

ParseError wraps multiple errors but did not implement the
Unwrap() []error interface introduced in Go 1.20. This makes
errors.Is and errors.As unable to inspect the underlying errors.

Add the Unwrap method so callers can use standard library error
inspection tools with ParseError.

Fixes temoto#47
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.

ParseError: add Unwrap() []error method

1 participant