Documentation / @agentick/shared / StateError
Class: StateError ​
Defined in: errors.ts:387
Error thrown when an operation is attempted in an invalid state.
Example ​
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 ​
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 ​
current ​
readonlycurrent:string
Defined in: errors.ts:389
Current state
details ​
readonlydetails:Record<string,unknown>
Defined in: errors.ts:105
Additional error details
Inherited from ​
expectedState? ​
readonlyoptionalexpectedState:string
Defined in: errors.ts:392
Expected/required state (optional)
Methods ​
alreadyComplete() ​
staticalreadyComplete(operation):StateError
Defined in: errors.ts:426
Create error for "already complete" state
Parameters ​
operation ​
string
Returns ​
StateError
fromJSON() ​
staticfromJSON(json):AgentickError
Defined in: errors.ts:169
Create error from serialized format
Parameters ​
json ​
Returns ​
Inherited from ​
notReady() ​
staticnotReady(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)