forked from i-am-bee/bee-agent-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.ts
22 lines (20 loc) · 846 Bytes
/
base.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { FrameworkError } from "bee-agent-framework/errors";
const error = new FrameworkError(
"Function 'getUser' has failed.",
[
new FrameworkError("Cannot retrieve data from the API.", [
new Error("User with given ID does not exist!"),
]),
],
{
context: { input: { id: "123" } },
isFatal: true,
isRetryable: false,
},
);
console.log("Message", error.message); // Main error message
console.log("Meta", { fatal: error.isFatal, retryable: error.isRetryable }); // Is the error fatal/retryable?
console.log("Context", error.context); // Context in which the error occurred
console.log(error.explain()); // Human-readable format without stack traces (ideal for LLMs)
console.log(error.dump()); // Full error dump, including sub-errors
console.log(error.getCause()); // Retrieve the initial cause of the error