Skip to content

Documentation / @agentick/core / GuardError

Class: GuardError

Defined in: shared/src/errors.ts:681

Error thrown when a guard denies access to a procedure or resource.

Example

typescript
throw GuardError.role(['admin', 'moderator']);
throw GuardError.denied('Insufficient permissions', { resource: 'settings' });

Extends

Extended by

Constructors

Constructor

new GuardError(message, guardType?, details?, cause?): GuardError

Defined in: shared/src/errors.ts:685

Parameters

message

string

guardType?

string

details?

Record<string, unknown> = {}

cause?

Error

Returns

GuardError

Overrides

AgentickError.constructor

Properties

cause?

readonly optional cause: Error

Defined in: shared/src/errors.ts:108

Original error that caused this error

Inherited from

AgentickError.cause


code

readonly code: AgentickErrorCode

Defined in: shared/src/errors.ts:102

Unique error code for programmatic handling

Inherited from

AgentickError.code


details

readonly details: Record<string, unknown>

Defined in: shared/src/errors.ts:105

Additional error details

Inherited from

AgentickError.details


guardType?

readonly optional guardType: string

Defined in: shared/src/errors.ts:683

Type of guard that denied access

Methods

denied()

static denied(reason, details?): GuardError

Defined in: shared/src/errors.ts:706

Create a custom guard denied error

Parameters

reason

string

details?

Record<string, unknown>

Returns

GuardError


fromJSON()

static fromJSON(json): AgentickError

Defined in: shared/src/errors.ts:169

Create error from serialized format

Parameters

json

SerializedAgentickError

Returns

AgentickError

Inherited from

AgentickError.fromJSON


role()

static role(roles): GuardError

Defined in: shared/src/errors.ts:699

Create a role-based guard error

Parameters

roles

string[]

Returns

GuardError


toJSON()

toJSON(): SerializedAgentickError

Defined in: shared/src/errors.ts:137

Serialize error for transport (JSON-safe)

Returns

SerializedAgentickError

Inherited from

AgentickError.toJSON

Released under the ISC License.