Skip to content

Documentation / @agentick/shared / StateError

Class: StateError ​

Defined in: errors.ts:387

Error thrown when an operation is attempted in an invalid state.

Example ​

typescript
throw new StateError('streaming', 'completed', 'Cannot send message to completed execution');
throw new StateError('initializing', 'ready', 'Engine is still initializing');

Extends ​

Constructors ​

Constructor ​

new StateError(current, expectedState, message, code?, cause?): StateError

Defined in: errors.ts:394

Parameters ​

current ​

string

expectedState ​

string | undefined

message ​

string

code? ​

"STATE_INVALID" | "STATE_TRANSITION" | "STATE_NOT_READY" | "STATE_ALREADY_COMPLETE"

cause? ​

Error

Returns ​

StateError

Overrides ​

AgentickError.constructor

Properties ​

cause? ​

readonly optional cause: Error

Defined in: errors.ts:108

Original error that caused this error

Inherited from ​

AgentickError.cause


code ​

readonly code: AgentickErrorCode

Defined in: errors.ts:102

Unique error code for programmatic handling

Inherited from ​

AgentickError.code


current ​

readonly current: string

Defined in: errors.ts:389

Current state


details ​

readonly details: Record<string, unknown>

Defined in: errors.ts:105

Additional error details

Inherited from ​

AgentickError.details


expectedState? ​

readonly optional expectedState: string

Defined in: errors.ts:392

Expected/required state (optional)

Methods ​

alreadyComplete() ​

static alreadyComplete(operation): StateError

Defined in: errors.ts:426

Create error for "already complete" state

Parameters ​

operation ​

string

Returns ​

StateError


fromJSON() ​

static fromJSON(json): AgentickError

Defined in: errors.ts:169

Create error from serialized format

Parameters ​

json ​

SerializedAgentickError

Returns ​

AgentickError

Inherited from ​

AgentickError.fromJSON


notReady() ​

static notReady(component, current): StateError

Defined in: errors.ts:414

Create error for "not ready" state

Parameters ​

component ​

string

current ​

string

Returns ​

StateError


toJSON() ​

toJSON(): SerializedAgentickError

Defined in: errors.ts:137

Serialize error for transport (JSON-safe)

Returns ​

SerializedAgentickError

Inherited from ​

AgentickError.toJSON

Released under the ISC License.