Files
falyx/falyx/exceptions.py
Roland Thomas 7f63e16097 feat: Add module docs, Enum coercion, tracebacks, and toggle improvements
- Add comprehensive module docstrings across the codebase for better clarity and documentation.
- Refactor Enum classes (e.g., FileType, ConfirmType) to use `_missing_` for built-in coercion from strings.
- Add `encoding` attribute to `LoadFileAction`, `SaveFileAction`, and `SelectFileAction` for more flexible file handling.
- Enable lazy file loading by default in `SelectFileAction` to improve performance.
- Simplify bottom bar toggle behavior: all toggles now use `ctrl+<key>`, eliminating the need for key conflict checks with Falyx commands.
- Add `ignore_in_history` attribute to `Command` to refine how `ExecutionRegistry` identifies the last valid result.
- Improve History command output: now includes tracebacks when displaying exceptions.
2025-07-19 14:44:43 -04:00

66 lines
1.9 KiB
Python

# Falyx CLI Framework — (c) 2025 rtj.dev LLC — MIT Licensed
"""
Defines all custom exception classes used in the Falyx CLI framework.
These exceptions provide structured error handling for common failure cases,
including command conflicts, invalid actions or hooks, parser errors, and execution guards
like circuit breakers or empty workflows.
All exceptions inherit from `FalyxError`, the base exception for the framework.
Exception Hierarchy:
- FalyxError
├── CommandAlreadyExistsError
├── InvalidHookError
├── InvalidActionError
├── NotAFalyxError
├── CircuitBreakerOpen
├── EmptyChainError
├── EmptyGroupError
├── EmptyPoolError
└── CommandArgumentError
These are raised internally throughout the Falyx system to signal user-facing or
developer-facing problems that should be caught and reported.
"""
class FalyxError(Exception):
"""Custom exception for the Menu class."""
class CommandAlreadyExistsError(FalyxError):
"""Exception raised when an command with the same key already exists in the menu."""
class InvalidHookError(FalyxError):
"""Exception raised when a hook is not callable."""
class InvalidActionError(FalyxError):
"""Exception raised when an action is not callable."""
class NotAFalyxError(FalyxError):
"""Exception raised when the provided submenu is not an instance of Menu."""
class CircuitBreakerOpen(FalyxError):
"""Exception raised when the circuit breaker is open."""
class EmptyChainError(FalyxError):
"""Exception raised when the chain is empty."""
class EmptyGroupError(FalyxError):
"""Exception raised when the chain is empty."""
class EmptyPoolError(FalyxError):
"""Exception raised when the chain is empty."""
class CommandArgumentError(FalyxError):
"""Exception raised when there is an error in the command argument parser."""