Skip to main content

Class: abstract ChiveError

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

Base error class for all Chive frontend errors.

Remarks

Follows the same pattern as backend ChiveError (src/types/errors.ts). All frontend errors should extend this class rather than the native Error class. This ensures consistent error code structure, enables error cause chaining for debugging, captures proper stack traces, and allows type discrimination via instanceof.

Never throw raw strings or objects; always use Error classes.

Example

class CustomError extends ChiveError {
readonly code = 'CUSTOM_ERROR';

constructor(message: string) {
super(message);
}
}

throw new CustomError('Something went wrong');

Extends

  • Error

Extended by

Constructors

new ChiveError()

new ChiveError(message, cause?): ChiveError

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

Creates a new ChiveError.

Parameters

message

string

Human-readable error message

cause?

Error

Original error (if chained)

Returns

ChiveError

Overrides

Error.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.

Overrides

Error.cause


code

abstract readonly code: string

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

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).

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


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

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.