openapi-generator
openapi-generator copied to clipboard
[go-server] add field name in parsing error messages
Currently when a min/max value for a number field is not respected, the api only returns a generic error message without providing any useful information to fix the request. This commit add the field name to the error message to help the user of the API.
Try to be more user friendly on error messages
Any feedbacks appreciated @antihax @grokify @kemokemo @jirikuncar @ph4r5h4d @lwj5
It would be better if the errors were wrapped, instead of passing the name into the function.
fmt.Errorf(“param name: %w” err)
there’s also nested ParsingError which we might want to remove. I think the error handling in this quite old before the error wrapping came out
Actually, I changed a bit the way to do it to add a Param field to ErrParsing so it can apply to all parsing error (eg: WithRequire, WithParse, ...). So the original error is kept. Let me know if it looks better to you.
Yes it looks good. Let me take a deeper look and approve it tmr
Lgtm. I’ll update the error handler with errors.As() to ensure errors are handled correctly in another PR