Skip to content

Exceptions

Exception hierarchy exported by ezplog.

🔍 API

EzplError

EzplError(message: str, error_code: str | None = None)

Bases: Exception

Base exception class for all Ezpl-related errors.

All custom exceptions in the Ezpl framework inherit from this base class, enabling centralized exception handling and consistent error reporting. Each exception includes a message and optional error code for categorization.

Initialize the Ezpl error.

Parameters:

Name Type Description Default
message str

Human-readable error message

required
error_code str | None

Optional error code for categorization and debugging

None
Note

Error codes follow the pattern: COMPONENT_ERROR or OPERATION_ERROR (e.g., "CONFIG_ERROR", "FILE_ERROR") for consistent error tracking.

ConfigurationError

ConfigurationError(message: str, config_key: str | None = None)

Bases: EzplError

Exception raised for configuration-related errors.

This exception is raised when configuration loading, validation, or processing encounters issues. The optional config_key attribute helps identify which configuration parameter caused the problem.

Initialize the configuration error.

Parameters:

Name Type Description Default
message str

Human-readable error message

required
config_key str | None

Optional configuration key that caused the error

None

LoggingError

LoggingError(message: str, handler_type: str | None = None)

Bases: EzplError

Exception raised for logging-related errors.

This exception covers issues with logging operations such as file writing, format processing, or handler initialization. The optional handler_type attribute identifies which handler (console, file) caused the error.

Initialize the logging error.

Parameters:

Name Type Description Default
message str

Human-readable error message

required
handler_type str | None

Optional handler type that caused the error (e.g., "file", "console")

None

ValidationError

ValidationError(message: str, field_name: str | None = None, value: str | None = None)

Bases: EzplError

Exception raised for validation errors.

This exception is raised when input validation fails (e.g., invalid log levels, malformed configuration values). The optional field_name and value attributes help identify what was being validated when the error occurred.

Initialize the validation error.

Parameters:

Name Type Description Default
message str

Human-readable error message

required
field_name str | None

Optional field name that failed validation

None
value str | None

Optional value that failed validation

None

InitializationError

InitializationError(message: str, component: str | None = None)

Bases: EzplError

Exception raised for initialization errors.

This exception is raised when Ezpl components fail to initialize properly. The optional component attribute identifies which component (printer, logger, config) encountered the initialization issue.

Initialize the initialization error.

Parameters:

Name Type Description Default
message str

Human-readable error message

required
component str | None

Optional component that failed to initialize

None

FileOperationError

FileOperationError(message: str, file_path: str | None = None, operation: str | None = None)

Bases: EzplError

Exception raised for file operation errors.

This exception covers issues with file operations (reading, writing, creating files). The optional file_path and operation attributes help identify which file and operation (read, write, create) failed.

Initialize the file operation error.

Parameters:

Name Type Description Default
message str

Human-readable error message

required
file_path str | None

Optional file path that caused the error

None
operation str | None

Optional operation that failed (e.g., "read", "write", "create")

None

HandlerError

HandlerError(message: str, handler_name: str | None = None)

Bases: EzplError

Exception raised for handler-related errors.

This exception covers issues with logging handlers (initialization, configuration, operation failures). The optional handler_name attribute identifies which handler (EzPrinter, EzLogger) caused the problem.

Initialize the handler error.

Parameters:

Name Type Description Default
message str

Human-readable error message

required
handler_name str | None

Optional handler name that caused the error

None