Skip to main content

Class: AuthorizationError

Defined in: src/types/errors.ts:288

Authorization error for insufficient permissions.

Remarks​

Thrown when an authenticated user attempts an action they don't have permission to perform.

HTTP mapping: 403 Forbidden

Example​

if (!user.hasScope('write:eprints')) {
throw new AuthorizationError(
'Missing required scope',
'write:eprints'
);
}

Extends​

Constructors​

new AuthorizationError()​

new AuthorizationError(message, requiredScope?): AuthorizationError

Defined in: src/types/errors.ts:302

Creates a new AuthorizationError.

Parameters​

message​

string

Description of authorization failure

requiredScope?​

string

Required scope (e.g., 'write:eprints')

Returns​

AuthorizationError

Overrides​

ChiveError.constructor

Properties​

cause?​

readonly optional cause: 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​

ChiveError.cause


code​

readonly code: "AUTHORIZATION_ERROR" = 'AUTHORIZATION_ERROR'

Defined in: src/types/errors.ts:289

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


requiredScope?​

readonly optional requiredScope: string

Defined in: src/types/errors.ts:294

Required scope that the user lacks (if applicable).