Explorar o código

wrap request read error as bad request

Aneurin Barker Snook hai 1 ano
pai
achega
33eba7de84
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      body.go

+ 1 - 1
body.go

@@ -11,7 +11,7 @@ import (
 func ReadRequestJSON(req *http.Request, v any) error {
 	data, err := io.ReadAll(req.Body)
 	if err != nil {
-		return err
+		return ErrBadRequest.WithError(err)
 	}
 	return json.Unmarshal(data, v)
 }