Skip to content

Commit d85d50d

Browse files
committed
Remove error printouts
We shouldn't print our own error messages from the middleware, allow callers' loggers to handle this themselves.
1 parent a2c6573 commit d85d50d

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

oapi_validate.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,37 +72,31 @@ func ValidateRequestFromContext(ctx echo.Context, router *openapi3filter.Router)
7272
case *openapi3filter.RouteError:
7373
// We've got a bad request, the path requested doesn't match
7474
// either server, or path, or something.
75-
ctx.Logger().Errorf("error finding request route for %s: %s",
76-
req.URL.String(), e.Reason)
7775
return echo.NewHTTPError(http.StatusBadRequest, e.Reason)
7876
default:
7977
// This should never happen today, but if our upstream code changes,
8078
// we don't want to crash the server, so handle the unexpected error.
81-
ctx.Logger().Errorf("error finding route %s: %s", req.URL.String(), err)
8279
return echo.NewHTTPError(http.StatusInternalServerError,
83-
"error validating request")
80+
fmt.Sprintf("error validating route: %s", err.Error()))
8481
}
8582
}
8683

8784
err = openapi3filter.ValidateRequest(context.Background(),
8885
&openapi3filter.RequestValidationInput{
89-
Request: req,
90-
PathParams: pathParams,
91-
Route: route,
86+
Request: req,
87+
PathParams: pathParams,
88+
Route: route,
9289
})
9390
if err != nil {
9491
switch e := err.(type) {
9592
case *openapi3filter.RequestError:
9693
// We've got a bad request
97-
ctx.Logger().Errorf("request validation failed for %s: %s",
98-
req.URL.String(), e.Reason)
9994
return echo.NewHTTPError(http.StatusBadRequest, e.Reason)
10095
default:
10196
// This should never happen today, but if our upstream code changes,
10297
// we don't want to crash the server, so handle the unexpected error.
103-
ctx.Logger().Errorf("error validating request for %s: %s", req.URL.String(), err)
10498
return echo.NewHTTPError(http.StatusInternalServerError,
105-
"error validating request")
99+
fmt.Sprintf("error validating request: %s", err))
106100
}
107101
}
108102
return nil

0 commit comments

Comments
 (0)