Unwrap strict errors (#1012)

This commit is contained in:
Étienne BERSAC
2025-12-21 16:20:24 +01:00
committed by GitHub
parent a0e8464967
commit 4369957cb4
2 changed files with 27 additions and 1 deletions
+12 -1
View File
@@ -54,6 +54,17 @@ func (s *StrictMissingError) String() string {
return buf.String()
}
// Unwrap returns wrapped decode errors
//
// Implements errors.Join() interface.
func (s *StrictMissingError) Unwrap() []error {
var errs []error
for i := range s.Errors {
errs = append(errs, &s.Errors[i])
}
return errs
}
type Key []string
// Error returns the error message contained in the DecodeError.
@@ -78,7 +89,7 @@ func (e *DecodeError) Key() Key {
return e.key
}
// decodeErrorFromHighlight creates a DecodeError referencing a highlighted
// wrapDecodeError creates a DecodeError referencing a highlighted
// range of bytes from document.
//
// highlight needs to be a sub-slice of document, or this function panics.