diff --git a/decode.go b/decode.go index afc005c..8c705ec 100644 --- a/decode.go +++ b/decode.go @@ -607,6 +607,16 @@ type unknownFieldError struct { err error } +func (e *unknownFieldError) PrettyPrint(p errors.Printer, colored, inclSource bool) error { + var pp errors.PrettyPrinter + if errors.As(e.err, &pp) { + return pp.PrettyPrint(p, colored, inclSource) + } + + p.Print(e) + return nil +} + func (e *unknownFieldError) Error() string { return e.err.Error() } @@ -623,6 +633,16 @@ type duplicateKeyError struct { err error } +func (e *duplicateKeyError) PrettyPrint(p errors.Printer, colored, inclSource bool) error { + var pp errors.PrettyPrinter + if errors.As(e.err, &pp) { + return pp.PrettyPrint(p, colored, inclSource) + } + + p.Print(e) + return nil +} + func (e *duplicateKeyError) Error() string { return e.err.Error() }