forked from Lilly-Protocol/agentlily-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntime-errors.ts
More file actions
41 lines (38 loc) · 933 Bytes
/
Copy pathruntime-errors.ts
File metadata and controls
41 lines (38 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
export type RuntimeErrorCode =
| "RUNTIME_NOT_STARTED"
| "RUNTIME_ALREADY_STARTED"
| "RUNTIME_ALREADY_STOPPED"
| "TOOL_NOT_FOUND"
| "DUPLICATE_TOOL"
| "INVALID_TASK"
| "EXECUTION_FAILED"
| "MAX_TOOL_CALLS_EXCEEDED";
export class RuntimeError extends Error {
public readonly code: RuntimeErrorCode;
public readonly details: Record<string, unknown> | undefined;
public constructor(
code: RuntimeErrorCode,
message: string,
details?: Record<string, unknown>
) {
super(message);
this.name = "RuntimeError";
this.code = code;
this.details = details;
}
public toJSON(): {
name: string;
code: RuntimeErrorCode;
message: string;
details: Record<string, unknown> | undefined;
stack: string | undefined;
} {
return {
name: this.name,
code: this.code,
message: this.message,
details: this.details,
stack: this.stack
};
}
}