Disclaimer: The notes below may refer to the TypeScript version or missing files as the Python version moves toward parity in the near future. Additional Python examples coming soon. TODO
Error handling is a critical part of any JavaScript application, especially when dealing with asynchronous operations, various error types, and error propagation across multiple layers. In the BeeAI Framework, we provide a robust and consistent error-handling structure that ensures reliability and ease of debugging.
All errors thrown within the BeeAI Framework extend from the base FrameworkError class.
Benefits of using FrameworkError
:
- Multiple Error Handling: Supports handling multiple errors simultaneously, which is particularly useful in asynchronous or concurrent operations.
- Preserved Error Chains: Retains the full history of errors, giving developers greater context for debugging.
- Consistent Structure: All errors across the framework share a uniform structure, simplifying error tracking and management.
- Native Support: Built on native Python functionality, avoiding the need for additional dependencies while leveraging familiar mechanisms.
- Utility Functions: Includes methods for formatting error stack traces and explanations, making them suitable for use with LLMs and other external tools.
This structure ensures that users can trace the complete error history while clearly identifying any errors originating from the BeeAI Framework.
_Source: /examples/errors/base.py TODO
The BeeAI Framework extends FrameworkError to create specialized error classes for different components. This ensures that each part of the framework has clear and well-defined error types, improving debugging and error handling.
Tip
Casting an unknown error to a FrameworkError
can be done by calling the FrameworkError.ensure
static method (example TODO).
When a tool encounters an error, it throws a ToolError
, which extends FrameworkError
. If input validation fails, a ToolInputValidationError
(which extends ToolError
) is thrown.
_Source: /examples/errors/tool.py TODO
Tip
If you throw a ToolError
intentionally in a custom tool, the framework will not apply any additional "wrapper" errors, preserving the original error context.
Throw AgentError
class which extends FrameworkError
class.
Throw PromptTemplateError
class which extends FrameworkError
class.
Throw LoggerError
class which extends FrameworkError
class.
Throw SerializerError
class which extends FrameworkError
class.