Class: ValidationError
Defined in: src/types/errors.ts:212
Validation error for invalid input data.
Remarks
Thrown when input data fails validation rules (e.g., required fields, format constraints, business rules).
HTTP mapping: 400 Bad Request
Example
if (!eprint.title) {
throw new ValidationError(
'Eprint title is required',
'title',
'required'
);
}
Extends
Constructors
new ValidationError()
new ValidationError(
message,field?,constraint?,cause?):ValidationError
Defined in: src/types/errors.ts:235
Creates a new ValidationError.
Parameters
message
string
Description of validation failure
field?
string
Field that failed validation
constraint?
string
Constraint that was violated
cause?
Error
Original error (if chained)
Returns
Overrides
Properties
cause?
readonlyoptionalcause:Error
Defined in: src/types/errors.ts:71
Original error that caused this error (if any).
Remarks
Error chaining allows tracking the full error context through multiple layers of the application. Useful for debugging complex error scenarios.
Example
try {
await fetchData();
} catch (err) {
throw new ValidationError('Failed to validate data', 'field', 'required', err as Error);
}
Inherited from
code
readonlycode:"VALIDATION_ERROR"='VALIDATION_ERROR'
Defined in: src/types/errors.ts:213
Machine-readable error code.
Remarks
Error codes are unique identifiers for error types, enabling programmatic error handling (switch statements, error maps), error tracking in monitoring systems, and client-side error translation (i18n).
Overrides
constraint?
readonlyoptionalconstraint:string
Defined in: src/types/errors.ts:225
Constraint that was violated (if applicable).
Example
'required', 'min_length', 'max_length', 'pattern'
field?
readonlyoptionalfield:string
Defined in: src/types/errors.ts:218
Field that failed validation (if applicable).