service: FieldErrors rendered as "Internal Server Error"
FieldErrors results in 500 status code being rendered for two reasons:
Errorsmiddleware explicitly looks forerrs.Errortype and if not found, returns 500 status code,httpStatusinterface is not yet implemented forFieldErrors, thereforecase error:switch case insideweb.Responsewins and results inInternal Server Error.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (16 by maintainers)
We agree the parseFilter function must return an
error. We can’t walk away from this idiom.We want a
FieldsErrorwith multiple reported problems when callingparseFilterWe need an
*errs.Errorbecause that is what implements the encoder interface.I think this commit provides the solution.
https://github.com/ardanlabs/service/commit/d818ca8ca52e0237701b0b5b57fa0938a15f48ab
I really would like to have just the 1 error type that implements the encoder interface. This better controls what can flow through the system as it related to errors.
Nice catch.
I think the change needs to be for that NewFieldsError to return an errs.Error with the field error wrapped. To fix the other to type assert to errs.Error
let me look at this today.