Ticket #1763 (closed enhancement: fixed)
Error messages for record validation in importData are too vague (patch provided)
| Reported by: | boutell | Owned by: | jwage |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0.6 |
| Component: | Attributes | Version: | 1.0.4 |
| Severity: | Keywords: | fixtures | |
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | yes |
Description
When loading data from a fixtures file, such as a YAML file in a Symfony project, any sort of error in validation produces this highly generic message:
Validation error in class Page
The class name is the only hint given as to where the problem is.
Since the Doctrine CLI code catches all lower-level exceptions, calls getMessage() on them, and throws a new exception with only that information, it is not possible for higher-level application code to address this problem directly.
I have addressed it by upgrading the generateMessage() method of Doctrine_Validator_Exception (see attachment).
My version of generateMessage() provides:
The fields that failed validation The specific validation errors (for instance, "type") The first 50 characters of the first five fields of the record, for context
Example output:
Validation error in class Page
Errors in the following fields:
Field: title Errors: type
First five fields (for context):
id: title: I love trees
This makes debugging problems with fixtures files about 10,000% more practical.
Since there are no API changes I hope this can be included in the 1.0.x series where it could make a big difference in Doctrine's acceptance within Symfony, which relies heavily on the Doctrine CLI. There has been quite a bit of muttering about the opaqueness of validation error messages.