all2md.exceptions
Custom exceptions for the all2md library.
This module defines specialized exception classes for various error conditions that can occur during document parsing and conversion operations. These exceptions provide more specific error information than generic built-ins.
Exception Hierarchy
All2MdError (base exception)
ValidationError (parameter/option validation) - InvalidOptionsError (wrong options class for parser) - PageRangeError (page range parsing errors)
FileError (file access and I/O) - FileNotFoundError (file doesn’t exist) - FileAccessError (permissions, locked files) - MalformedFileError (corrupted/invalid file structure)
FormatError (unsupported/unknown formats)
ParsingError (input document parsing failures) - PasswordProtectedError (password-protected files)
RenderingError (output generation failures) - OutputWriteError (file write failures)
TransformError (AST transformation failures)
SecurityError (security violations) - NetworkSecurityError (SSRF, network violations) - ZipFileSecurityError (zip bombs, path traversal)
DependencyError (missing/incompatible packages)
- exception all2md.exceptions.All2MdError
Bases:
ExceptionBase exception class for all all2md-specific errors.
This serves as the root exception class for all custom exceptions raised by the all2md library. Catching this will catch all library-specific errors.
- Parameters:
message (str) – Human-readable description of the error
original_error (Exception, optional) – The original exception that caused this error, if applicable
- Variables:
message (str) – The error message
original_error (Exception or None) – The wrapped original exception, if any
Initialize the error with a message and optional original exception.
- __init__(message: str, original_error: Exception | None = None)
Initialize the error with a message and optional original exception.
- exception all2md.exceptions.ValidationError
Bases:
All2MdErrorException raised for invalid input parameters or options.
This exception covers validation errors such as: - Invalid parameter values - Invalid parameter combinations - Invalid option specifications
- Parameters:
message (str) – Description of the validation error
parameter_name (str, optional) – Name of the invalid parameter
parameter_value (any, optional) – The invalid value that was provided
original_error (Exception, optional) – The original exception that caused this error
- Variables:
parameter_name (str or None) – The name of the problematic parameter
parameter_value (any) – The value that caused the error
Initialize the validation error with parameter details.
- __init__(message: str, parameter_name: str | None = None, parameter_value: Any = None, original_error: Exception | None = None)
Initialize the validation error with parameter details.
- exception all2md.exceptions.InvalidOptionsError
Bases:
ValidationErrorException raised when incorrect options class is provided to a parser.
This exception is raised when a parser receives an options object of the wrong type. For example, passing PdfOptions to a plaintext parser.
- Parameters:
converter_name (str) – Name of the parser that received invalid options
expected_type (type) – The expected options class type
received_type (type) – The actual options class type that was received
message (str, optional) – Custom error message. If not provided, generates a helpful message
original_error (Exception, optional) – The original exception that caused this error
- Variables:
Initialize the invalid options error.
- exception all2md.exceptions.PageRangeError
Bases:
ValidationErrorException raised for invalid page range specifications.
- Parameters:
message (str) – Description of the page range error
parameter_value (any, optional) – The invalid page range value
original_error (Exception, optional) – The original exception that caused this error
Initialize the page range error.
- __init__(message: str, parameter_value: Any = None, original_error: Exception | None = None)
Initialize the page range error.
- exception all2md.exceptions.FileError
Bases:
All2MdErrorBase exception for file access and I/O errors.
This exception covers file-related errors such as: - File not found - Permission denied - File locked or in use - Invalid file structure
- Parameters:
message (str) – Description of the file error
file_path (str, optional) – Path to the problematic file
original_error (Exception, optional) – The original exception that caused this error
- Variables:
file_path (str or None) – Path to the file that caused the error
Initialize the file error with path and message.
- __init__(message: str, file_path: str | None = None, original_error: Exception | None = None)
Initialize the file error with path and message.
- exception all2md.exceptions.FileNotFoundError
Bases:
FileErrorException raised when a file cannot be found.
- Parameters:
file_path (str) – Path to the file that was not found
message (str, optional) – Custom error message. If not provided, uses default message
original_error (Exception, optional) – The original exception that caused this error
Initialize the file not found error.
- __init__(file_path: str, message: str | None = None, original_error: Exception | None = None)
Initialize the file not found error.
- exception all2md.exceptions.FileAccessError
Bases:
FileErrorException raised when a file cannot be accessed.
This includes permission errors, locked files, etc.
- Parameters:
file_path (str) – Path to the file that cannot be accessed
message (str, optional) – Custom error message. If not provided, uses default message
original_error (Exception, optional) – The original exception that caused this error
Initialize the file access error.
- __init__(file_path: str, message: str | None = None, original_error: Exception | None = None)
Initialize the file access error.
- exception all2md.exceptions.MalformedFileError
Bases:
FileErrorException raised when a file has invalid or corrupted structure.
- Parameters:
file_path (str, optional) – Path to the malformed file
message (str, optional) – Description of what is malformed
original_error (Exception, optional) – The original exception that caused this error
Initialize the malformed file error.
- __init__(message: str, file_path: str | None = None, original_error: Exception | None = None)
Initialize the malformed file error.
- exception all2md.exceptions.FormatError
Bases:
All2MdErrorException raised when attempting to process an unsupported file format.
This exception indicates that the requested file format or conversion operation is not supported by the current version of all2md.
- Parameters:
message (str, optional) – Custom error message
format_type (str, optional) – The unsupported format type (file extension or MIME type)
supported_formats (list[str], optional) – List of supported formats for reference
original_error (Exception, optional) – The original exception that caused this error
- Variables:
format_type (str or None) – The format that was not supported
supported_formats (list[str] or None) – Available supported formats
Initialize the format error.
- __init__(message: str | None = None, format_type: str | None = None, supported_formats: list[str] | None = None, original_error: Exception | None = None)
Initialize the format error.
- exception all2md.exceptions.ParsingError
Bases:
All2MdErrorException raised when document parsing fails.
This exception is raised when the parsing process encounters an error that prevents successful completion, such as: - Malformed document structure - Unsupported document features - Password-protected files
- Parameters:
message (str) – Description of the parsing failure
parsing_stage (str, optional) – The stage of parsing where the error occurred
original_error (Exception, optional) – The underlying exception that caused the parsing failure
- Variables:
parsing_stage (str or None) – Where in the parsing process the error occurred
Initialize the parsing error.
- __init__(message: str, parsing_stage: str | None = None, original_error: Exception | None = None)
Initialize the parsing error.
- exception all2md.exceptions.PasswordProtectedError
Bases:
ParsingErrorException raised when a file requires a password for access.
This exception is raised specifically when attempting to process a password-protected document without providing the correct password or when the provided password is incorrect.
- Parameters:
message (str, optional) – Custom error message. If not provided, uses default message
filename (str, optional) – Name of the file that requires a password
original_error (Exception, optional) – The original exception that caused this error
- Variables:
filename (str or None) – The name of the password-protected file, if provided
Initialize the password protected error.
- __init__(message: str | None = None, filename: str | None = None, original_error: Exception | None = None)
Initialize the password protected error.
- exception all2md.exceptions.RenderingError
Bases:
All2MdErrorException raised when output rendering fails.
This exception is raised when the rendering process encounters an error that prevents successful completion, such as: - Missing required data or metadata - Internal processing errors - Unsupported AST nodes
- Parameters:
message (str) – Description of the rendering failure
rendering_stage (str, optional) – The stage of rendering where the error occurred
original_error (Exception, optional) – The underlying exception that caused the rendering failure
- Variables:
rendering_stage (str or None) – Where in the rendering process the error occurred
Initialize the rendering error.
- __init__(message: str, rendering_stage: str | None = None, original_error: Exception | None = None)
Initialize the rendering error.
- exception all2md.exceptions.OutputWriteError
Bases:
RenderingErrorException raised when writing output file fails.
- Parameters:
file_path (str) – Path to the output file that failed to write
message (str, optional) – Custom error message. If not provided, uses default message
original_error (Exception, optional) – The original exception that caused this error
- Variables:
file_path (str) – Path to the file that failed to write
Initialize the output write error.
- __init__(file_path: str, message: str | None = None, original_error: Exception | None = None)
Initialize the output write error.
- exception all2md.exceptions.TransformError
Bases:
All2MdErrorException raised when AST transformation fails.
This exception is raised when a transform operation encounters an error during AST processing.
- Parameters:
message (str) – Description of the transform failure
transform_name (str, optional) – Name of the transform that failed
original_error (Exception, optional) – The underlying exception that caused the transform failure
- Variables:
transform_name (str or None) – Name of the transform that failed
Initialize the transform error.
- __init__(message: str, transform_name: str | None = None, original_error: Exception | None = None)
Initialize the transform error.
- exception all2md.exceptions.SecurityError
Bases:
All2MdErrorBase exception for security violations.
This exception covers security-related errors such as: - SSRF (Server-Side Request Forgery) attempts - Path traversal attempts - Zip bomb attacks - Other security violations
- Parameters:
message (str) – Description of the security violation
original_error (Exception, optional) – The original exception that caused this error
Initialize the error with a message and optional original exception.
- exception all2md.exceptions.NetworkSecurityError
Bases:
SecurityErrorException raised when a network security violation is detected.
This includes SSRF attempts, blocked hosts, invalid URLs, etc.
- Parameters:
message (str) – Description of the network security violation
original_error (Exception, optional) – The original exception that caused this error
Initialize the error with a message and optional original exception.
- exception all2md.exceptions.ZipFileSecurityError
Bases:
SecurityErrorException raised when a zip file security violation is detected.
This includes zip bombs, path traversal attempts, excessive compression, etc.
- Parameters:
message (str) – Description of the zip file security violation
original_error (Exception, optional) – The original exception that caused this error
Initialize the error with a message and optional original exception.
- exception all2md.exceptions.ArchiveSecurityError
Bases:
SecurityErrorException raised when an archive file security violation is detected.
This includes archive bombs, path traversal attempts, excessive compression, etc. Applies to TAR, 7Z, and RAR archives.
- Parameters:
message (str) – Description of the archive security violation
original_error (Exception, optional) – The original exception that caused this error
Initialize the error with a message and optional original exception.
- exception all2md.exceptions.DependencyError
Bases:
All2MdErrorException raised when required dependencies are not available.
This exception is raised when attempting to use a converter that requires external packages that are not installed or don’t meet version requirements.
- Parameters:
converter_name (str) – Name of the converter requiring dependencies
missing_packages (list[tuple[str, str]]) – List of (package_name, version_spec) tuples for missing packages
version_mismatches (list[tuple[str, str, str]], optional) – List of (package_name, required_version, installed_version) tuples for packages with version mismatches
install_command (str, optional) – Suggested pip install command to resolve the issue
message (str, optional) – Custom error message. If not provided, generates a helpful message
- Variables:
converter_name (str) – The converter that has missing dependencies
missing_packages (list[tuple[str, str]]) – Packages that need to be installed
version_mismatches (list[tuple[str, str, str]]) – Packages with version mismatches
install_command (str) – Command to install missing dependencies
Initialize the dependency error with package details.
- __init__(converter_name: str, missing_packages: list[tuple[str, str]], version_mismatches: list[tuple[str, str, str]] | None = None, install_command: str = '', message: str | None = None, original_import_error: ImportError | None = None)
Initialize the dependency error with package details.