Entity Framework - reporting server validation errors (422) on the client
Under EF, data validations can occur at 3 points : 1) client-side : using html tags (minlength, maxlength required etc) - these will feed into the angular validation system, marking the form as valid/invalid. 2) Server-side - as data is moved into the EF class for an object, errors may be generated according to the DataAnnotations on this object 3) database - inside the SQL server, errors may be generated ( missing foreign references) e.g.
2) is new under EF. In this circumstance EF throws a DbEntityValidationException , which has the specific exceptions as a member collection. This collection of errors is being returned with HTTP code 422
https://stackoverflow.com/questions/16133923/400-vs-422-response-to-post-of-data
However, the client-side error handling scheme is not dealing with this or reporting correctly.
Comments (3)
-
-
Note I have noticed this at least once with School edit with a school name larger then the annotation on the entity. I've "fixed" it by correcting the maxlength (see
#239). But the issue described herein is still present and would be great to address it so leaving this open. -
- changed status to resolved
I think the frontend now handles various error correctly. Raise individual issues for new cases if/when found.
- Log in to comment
Yes, it would be nice to have a unified error handling that consistently reports clearly to the user what went wrong, where it went wrong and ideally an email sent to developers email list or something like that.