improve handling of validation errors