Class: NetworkError
Defined in: web/lib/errors.ts:442
Network error for connection failures.
Remarks
Thrown when the network request fails (e.g., no internet, DNS failure, connection timeout). Distinct from API errors which indicate the server responded with an error.
Example
try {
await fetch('/api/eprints');
} catch (err) {
if (err instanceof TypeError) {
throw new NetworkError('Network request failed', err);
}
throw err;
}
Extends
Constructors
new NetworkError()
new NetworkError(
message,cause?):NetworkError
Defined in: web/lib/errors.ts:451
Creates a new NetworkError.
Parameters
message
string
Description of the network failure
cause?
Error
Original fetch error
Returns
Overrides
Properties
cause?
readonlyoptionalcause: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
code
readonlycode:"NETWORK_ERROR"='NETWORK_ERROR'
Defined in: web/lib/errors.ts:443
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
Accessors
isRetryable
Get Signature
get isRetryable():
boolean
Defined in: web/lib/errors.ts:459
Whether this error is retryable.
Remarks
Override in subclasses to indicate whether the operation can be retried. Default is false (non-retryable).
Returns
boolean
Overrides
severity
Get Signature
get severity():
ErrorSeverity
Defined in: web/lib/errors.ts:455
Error severity for monitoring and alerting.
Remarks
Override in subclasses to customize severity based on error type. Default is 'medium' for most errors.
Returns
Overrides
Methods
toJSON()
toJSON():
SerializedError
Defined in: web/lib/errors.ts:120
Converts error to a plain object for structured logging.
Returns
Remarks
Produces a JSON-serializable object with all error properties, including nested cause chains.