Skip to main content

Class: ValidationError

Defined in: web/lib/errors.ts:281

Validation error for invalid input data.

Remarks​

Thrown when input data fails validation rules (e.g., required fields, format constraints, business rules).

Example​

if (!title.trim()) {
throw new ValidationError(
'Title is required',
'title',
'required'
);
}

Extends​

Constructors​

new ValidationError()​

new ValidationError(message, field?, constraint?, cause?): ValidationError

Defined in: web/lib/errors.ts:304

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​

ValidationError

Overrides​

ChiveError.constructor

Properties​

cause?​

readonly optional cause: Error

Defined in: web/lib/errors.ts:76

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.

Inherited from​

ChiveError.cause


code​

readonly code: "VALIDATION_ERROR" = 'VALIDATION_ERROR'

Defined in: web/lib/errors.ts:282

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​

ChiveError.code


constraint?​

readonly optional constraint: string

Defined in: web/lib/errors.ts:294

Constraint that was violated (if applicable).

Example​

'required', 'min_length', 'max_length', 'pattern'

field?​

readonly optional field: string

Defined in: web/lib/errors.ts:287

Field that failed validation (if applicable).

Accessors​

isRetryable​

Get Signature​

get isRetryable(): boolean

Defined in: web/lib/errors.ts:109

Whether this error is retryable.

Remarks​

Override in subclasses to indicate whether the operation can be retried. Default is false (non-retryable).

Returns​

boolean

Inherited from​

ChiveError.isRetryable


severity​

Get Signature​

get severity(): ErrorSeverity

Defined in: web/lib/errors.ts:98

Error severity for monitoring and alerting.

Remarks​

Override in subclasses to customize severity based on error type. Default is 'medium' for most errors.

Returns​

ErrorSeverity

Inherited from​

ChiveError.severity

Methods​

toJSON()​

toJSON(): SerializedError

Defined in: web/lib/errors.ts:120

Converts error to a plain object for structured logging.

Returns​

SerializedError

Remarks​

Produces a JSON-serializable object with all error properties, including nested cause chains.

Inherited from​

ChiveError.toJSON