Class: AuthorizationError
Defined in: web/lib/errors.ts:349
Authorization error for insufficient permissions.
Remarks
Thrown when an authenticated user attempts an action they don't have permission to perform.
Example
if (!user.canEdit(eprint)) {
throw new AuthorizationError(
'You do not have permission to edit this eprint',
'write:eprints'
);
}
Extends
Constructors
new AuthorizationError()
new AuthorizationError(
message,requiredScope?):AuthorizationError
Defined in: web/lib/errors.ts:363
Creates a new AuthorizationError.
Parameters
message
string
Description of authorization failure
requiredScope?
string
Required scope (e.g., 'write:eprints')
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:"AUTHORIZATION_ERROR"='AUTHORIZATION_ERROR'
Defined in: web/lib/errors.ts:350
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
requiredScope?
readonlyoptionalrequiredScope:string
Defined in: web/lib/errors.ts:355
Required scope that the user lacks (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
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
Inherited from
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.