Exceptions¶
Custom exception classes for LayoutLens with comprehensive error handling.
This module provides a hierarchy of custom exceptions for different error scenarios that can occur during LayoutLens operations, including API errors, screenshot failures, configuration issues, and analysis problems.
- exception layoutlens.exceptions.LayoutLensError(message, details=None)[source]¶
Bases:
ExceptionBase exception class for all LayoutLens-specific errors.
Provides common functionality for logging, error details storage, and string representation across all LayoutLens exceptions.
- message¶
The error message string.
- details¶
Dictionary of additional error context information.
- exception layoutlens.exceptions.ConfigurationError(message, config_file=None, missing_fields=None)[source]¶
Bases:
LayoutLensErrorException raised when there’s a configuration issue.
Covers invalid configuration files, missing required settings, malformed YAML, and incompatible configuration values.
- config_file¶
Path to the problematic configuration file.
- missing_fields¶
List of missing required configuration fields.
- exception layoutlens.exceptions.ValidationError(message, field=None, value=None)[source]¶
Bases:
LayoutLensErrorException raised when input validation fails.
Occurs when user-provided inputs don’t meet requirements, such as empty queries, invalid URLs, or malformed parameters.
- field¶
The field name that failed validation.
- value¶
The invalid value that was rejected.
- exception layoutlens.exceptions.AnalysisError(message, query=None, source=None, confidence=0.0)[source]¶
Bases:
LayoutLensErrorException raised when AI analysis fails.
Occurs when the AI provider fails to analyze screenshots, returns malformed responses, or encounters processing errors.
- query¶
The analysis query that failed.
- source¶
The source being analyzed.
- confidence¶
Confidence score (0.0 for failed analyses).
- exception layoutlens.exceptions.AuthenticationError(message='Invalid or missing API key')[source]¶
Bases:
LayoutLensErrorException raised when API authentication fails.
Covers invalid API keys, expired tokens, and permission problems.
- Parameters:
message (str)
- exception layoutlens.exceptions.LayoutFileNotFoundError(message, file_path=None)[source]¶
Bases:
LayoutLensErrorException raised when a required file is not found.
Occurs when attempting to access screenshots, HTML files, configuration files, or other required resources that don’t exist.
- file_path¶
The path to the missing file.