From 8bc49c945c1b393bcfb4d8df545c93593c9bd7c4 Mon Sep 17 00:00:00 2001 From: thinkofher Date: Sun, 18 Sep 2022 21:20:05 +0200 Subject: [PATCH] mime/multipart: use %w when wrapping error in NextPart Use "%w" instead of "%v" as format verb for error value in the NextPart method. This way it will be possible to use common go error utilities from std library when parsing from custom io.Readers. This issue was discovered during attempts to use http.Request.ParseMultipartForm together with http.MaxBytesHandler. --- src/mime/multipart/multipart.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mime/multipart/multipart.go b/src/mime/multipart/multipart.go index aa05ac8f9c..b3a904f0af 100644 --- a/src/mime/multipart/multipart.go +++ b/src/mime/multipart/multipart.go @@ -360,7 +360,7 @@ func (r *Reader) nextPart(rawPart bool) (*Part, error) { return nil, io.EOF } if err != nil { - return nil, fmt.Errorf("multipart: NextPart: %v", err) + return nil, fmt.Errorf("multipart: NextPart: %w", err) } if r.isBoundaryDelimiterLine(line) {