better error handling for validation errors