From 591c98bb315b8c840f94afbaa566dc6770f9d98c Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 10 Jan 2024 15:08:28 +0100 Subject: [PATCH] gqlerror: implement List.Unwrap (#290) Go 1.20 has added a new Unwrap method for error values holding multiple errors. Implement this method as that errors.Is/As work as expected. --- gqlerror/error.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gqlerror/error.go b/gqlerror/error.go index ba624fbc..483a086d 100644 --- a/gqlerror/error.go +++ b/gqlerror/error.go @@ -106,6 +106,14 @@ func (errs List) As(target interface{}) bool { return false } +func (errs List) Unwrap() []error { + l := make([]error, len(errs)) + for i, err := range errs { + l[i] = err + } + return l +} + func WrapPath(path ast.Path, err error) *Error { if err == nil { return nil