From 03a340b81bed33d0329897ec33cd29dab9831f82 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 9 Jan 2024 12:02:06 +0100 Subject: [PATCH] gqlerror: implement List.Unwrap 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