This commit adds the ParameterError interface that extends error to add
a ParameterName() method. This method is implemented by existing errors
that are currently returned when a parameter has an error (e.g.
InvalidParamFormatError).
To check from an error to see if that error was caused by a parameter,
the user can write
func(w http.ResponseWriter, r *http.Request, err error) {
if paramError, ok := err.(openapi.ParameterError); ok {
// Specifically write a 400 response with the parameter name in
// the body.
writeParamError(w, r, 400, paramError.ParameterName(), err)
return
}
writeError(w, r, 400, err)
}
This commit adds the ParameterError interface that extends error to add a ParameterName() method. This method is implemented by existing errors that are currently returned when a parameter has an error (e.g. InvalidParamFormatError).
To check from an error to see if that error was caused by a parameter, the user can write