Exceptions Reference
Comprehensive guide to exception handling in the Plexe Python library.
Plexe defines several exception types to provide clear information about errors that may occur during model building and usage. This reference documents all exception classes, their meanings, and how to handle them effectively.
Exception Hierarchy
Plexe’s exceptions inherit from a base PlexeError
class:
Note: This hierarchy reflects the current implementation and may expand in future versions.
Base Exception
PlexeError
Base exception for all Plexe-specific exceptions.
Specification Errors
SpecificationError
Base class for errors related to model specification.
InsufficientSpecificationError
Raised when the natural language specification is insufficiently detailed.
Example:
AmbiguousSpecificationError
Raised when the natural language specification is ambiguous or contradictory.
Example:
InvalidSchemaError
Raised when the input or output schema is invalid.
Example:
Instruction Errors
InstructionError
Base class for errors related to instructions provided for model building.
Example:
Constraint Errors
ConstraintError
Base class for errors related to constraints.
Example:
Runtime Errors
PlexeRuntimeError
Base class for runtime errors during model execution or training.
CodeExecutionError
Raised when code execution fails for reasons other than timeout.
Example:
Handling Exceptions
Note: The list of exception classes above represents the current implementation. In future versions, additional exception types may be added to provide more specific error information.
Basic Exception Handling
Specific Exception Handling
Prediction Error Handling
Best Practices
- Catch Specific Exceptions: Target the most specific exception class that makes sense for your use case.
- Log Detailed Information: Include full exception details in logs for debugging.
- Graceful Degradation: When possible, handle errors in a way that allows your application to continue functioning.
- User-Friendly Messages: Transform technical error details into actionable user messages.
- Retry Strategies: Implement retries for transient errors like LLM provider issues.
By understanding Plexe’s exception hierarchy, you can write more robust code that gracefully handles potential errors in your machine learning workflows.