Documentation / @agentick/shared / GuardError
Class: GuardError
Defined in: errors.ts:681
Error thrown when a guard denies access to a procedure or resource.
Example
throw GuardError.role(['admin', 'moderator']);
throw GuardError.denied('Insufficient permissions', { resource: 'settings' });Extends
Constructors
Constructor
new GuardError(
message,guardType?,details?,cause?):GuardError
Defined in: errors.ts:685
Parameters
message
string
guardType?
string
details?
Record<string, unknown> = {}
cause?
Error
Returns
GuardError
Overrides
Properties
cause?
readonlyoptionalcause:Error
Defined in: errors.ts:108
Original error that caused this error
Inherited from
code
readonlycode:AgentickErrorCode
Defined in: errors.ts:102
Unique error code for programmatic handling
Inherited from
details
readonlydetails:Record<string,unknown>
Defined in: errors.ts:105
Additional error details
Inherited from
guardType?
readonlyoptionalguardType:string
Defined in: errors.ts:683
Type of guard that denied access
Methods
denied()
staticdenied(reason,details?):GuardError
Defined in: errors.ts:706
Create a custom guard denied error
Parameters
reason
string
details?
Record<string, unknown>
Returns
GuardError
fromJSON()
staticfromJSON(json):AgentickError
Defined in: errors.ts:169
Create error from serialized format
Parameters
json
Returns
Inherited from
role()
staticrole(roles):GuardError
Defined in: errors.ts:699
Create a role-based guard error
Parameters
roles
string[]
Returns
GuardError
toJSON()
toJSON():
SerializedAgentickError
Defined in: errors.ts:137
Serialize error for transport (JSON-safe)