fitzzftw.patch.exceptions

        ---
config:
  height: 300px
  width: 300px

title: exceptions
---
classDiagram
  Exception <|-- FtwException
  FtwError <|-- FtwPatchError
  FtwError <|-- FtwProtocolError
  FtwException <|-- FtwError
  FtwPatchError <|-- PatchParseError
  TypeError <|-- FtwProtocolError
    

Inheritage diagramm for exceptions

exceptions

This module provides a specialized hierarchy of exceptions for the fitzzftw framework. It includes advanced introspection tools that adapt to the running Python version to handle Protocols and callables.

Core Features:

  • Protocol Validation: Uses FtwProtocolWrap and FtwProtocolError to generate highly detailed error messages when objects do not match required interfaces.

  • Signature Inspection: Employs fitzzftw.patch.current_312_313..FtwMethFuncWrap to accurately represent methods and functions (including ‘self’ injection) in diagnostic outputs.

  • Type Awareness: Automatically resolves type names and hints into human-readable strings for clearer debugging.

The primary goal of this module is to provide actionable implementation guides for the developer by resolving version-specific introspection differences (PEP 649/annotationlib vs. legacy typing).

Functions

protocol_error_message(obj, argument, *protocols)

Constructs a detailed, human-readable error message for protocol violations.

protocol_error_message(obj, argument, *protocols)[source]

Constructs a detailed, human-readable error message for protocol violations.

The message identifies the failing function and argument, then lists the requirements of the expected protocols (both data attributes and methods). It provides a clear blueprint of what needs to be implemented or overridden.

Parameters:
  • obj (Callable | None) – The callable (function or method) where the error occurred.

  • argument (str) – The name of the argument that failed the protocol check.

  • protocols – A variable number of protocol classes to check against.

Returns:

A formatted string containing the error details and requirements.

Return type:

str

Exceptions

FtwError

Base exception for all errors raised by the fitzzftw namespace.

FtwException

Base exception for all exceptions raised by the ftw module.

FtwPatchError

Base exception for all errors raised by the ftw_patch module.

FtwProtocolError

Exception raised when an object violates one or more required Protocols.

PatchParseError

Exception raised when an error occurs during the parsing of the patch file content.

exception FtwError[source]

Bases: FtwException

Base exception for all errors raised by the fitzzftw namespace.

Inheritance Hierarchy
exception FtwException[source]

Bases: Exception

Base exception for all exceptions raised by the ftw module.

Inheritance Hierarchy
exception FtwPatchError[source]

Bases: FtwError

Base exception for all errors raised by the ftw_patch module.

Inheritance Hierarchy
exception FtwProtocolError[source]

Bases: FtwError, TypeError

Exception raised when an object violates one or more required Protocols.

This error is specifically designed to work with the FtwProtocolWrap and FtwMethFuncWrap utilities. It captures the context of the failure—including the target function, the invalid argument, and the expected protocols—to generate a highly detailed cryptographic-style error message.

Inheritance Hierarchy

Variables:
  • _meth_func (Callable) – The function or method where the protocol violation occurred.

  • _arg_name (str) – The name of the argument that failed the check.

  • _protocols (tuple) – A collection of Protocol classes that were expected.

__init__(meth_func, arg_name, protocols)[source]

Initializes the error with the context of the protocol violation.

Parameters:
  • meth_func (Callable) – The callable that triggered the error.

  • arg_name (str) – The specific argument name that is non-compliant.

  • protocols (tuple) – The expected protocol(s) as a tuple.

exception PatchParseError[source]

Bases: FtwPatchError

Exception raised when an error occurs during the parsing of the patch file content.

Inheritance Hierarchy
__init__(message)[source]

Initializes the PatchParseError.

Parameters:

message (str) – The error message.