src.bluetooth_sig.gatt.exceptions¶
GATT exceptions for the Bluetooth SIG library.
Exceptions¶
Name | Description |
|---|---|
Base exception for all Bluetooth SIG related errors. |
|
Raised when characteristic encoding fails. |
|
Base exception for characteristic-related errors. |
|
Raised when characteristic parsing fails. |
|
Exception raised when characteristic data encoding fails. |
|
Exception raised when characteristic data parsing fails. |
|
Exception raised when characteristic data validation fails. |
|
Exception raised when an enum value is invalid. |
|
Exception raised when IEEE 11073 format parsing fails. |
|
Exception raised when there is insufficient data for parsing. |
|
Exception raised when a required dependency is missing for multi-characteristic parsing. |
|
Exception raised when a specific field fails to parse. |
|
Exception raised when expected characteristics are not found in a service. |
|
Base exception for service-related errors. |
|
Raised when a special sentinel value is detected. |
|
Exception raised when a template is incorrectly configured. |
|
Exception raised when a value has an unexpected type. |
|
Exception raised when attempting to use a UUID that already exists in SIG registry. |
|
Exception raised when a UUID is required but not provided or invalid. |
|
Exception raised when UUID resolution fails. |
|
Exception raised when a value is outside the expected range. |
|
Exception raised when YAML specification resolution fails. |
Module Contents¶
- exception src.bluetooth_sig.gatt.exceptions.BluetoothSIGError¶
Bases:
ExceptionBase exception for all Bluetooth SIG related errors.
- exception src.bluetooth_sig.gatt.exceptions.CharacteristicEncodeError(message: str, name: str, uuid: src.bluetooth_sig.types.uuid.BluetoothUUID, value: Any, validation: src.bluetooth_sig.types.data_types.ValidationAccumulator | None = None)¶
Bases:
CharacteristicErrorRaised when characteristic encoding fails.
- message¶
Human-readable error message
- name¶
Characteristic name
- uuid¶
Characteristic UUID
- value¶
The value that failed to encode
- validation¶
Accumulated validation results
- name¶
- uuid¶
- validation = None¶
- value¶
- exception src.bluetooth_sig.gatt.exceptions.CharacteristicError¶
Bases:
BluetoothSIGErrorBase exception for characteristic-related errors.
- exception src.bluetooth_sig.gatt.exceptions.CharacteristicParseError(message: str, name: str, uuid: src.bluetooth_sig.types.uuid.BluetoothUUID, raw_data: bytes, raw_int: int | None = None, field_errors: list[src.bluetooth_sig.types.ParseFieldError] | None = None, parse_trace: list[str] | None = None, validation: src.bluetooth_sig.types.data_types.ValidationAccumulator | None = None)¶
Bases:
CharacteristicErrorRaised when characteristic parsing fails.
Preserves all debugging context from parsing attempt.
- message¶
Human-readable error message
- name¶
Characteristic name
- uuid¶
Characteristic UUID
- raw_data¶
Exact bytes that failed (useful: hex dump debugging)
- raw_int¶
Extracted integer value (useful: check bit patterns)
- field_errors¶
Field-level errors (useful: complex multi-field characteristics)
- parse_trace¶
Step-by-step execution log (useful: debug parser flow)
- validation¶
Accumulated validation results (useful: see all warnings/errors)
- field_errors = []¶
- name¶
- parse_trace = []¶
- raw_data¶
- raw_int = None¶
- uuid¶
- validation = None¶
- exception src.bluetooth_sig.gatt.exceptions.DataEncodingError(characteristic: str, value: Any, reason: str)¶
Bases:
CharacteristicErrorException raised when characteristic data encoding fails.
- characteristic¶
- reason¶
- value¶
- exception src.bluetooth_sig.gatt.exceptions.DataParsingError(characteristic: str, data: bytes | bytearray, reason: str)¶
Bases:
CharacteristicErrorException raised when characteristic data parsing fails.
- characteristic¶
- data¶
- reason¶
- exception src.bluetooth_sig.gatt.exceptions.DataValidationError(field: str, value: Any, expected: str)¶
Bases:
CharacteristicErrorException raised when characteristic data validation fails.
- expected¶
- field¶
- value¶
- exception src.bluetooth_sig.gatt.exceptions.EnumValueError(field: str, value: Any, enum_class: type, valid_values: list[Any])¶
Bases:
DataValidationErrorException raised when an enum value is invalid.
- enum_class¶
- valid_values¶
- exception src.bluetooth_sig.gatt.exceptions.IEEE11073Error(data: bytes | bytearray, format_type: str, reason: str)¶
Bases:
DataParsingErrorException raised when IEEE 11073 format parsing fails.
- format_type¶
- exception src.bluetooth_sig.gatt.exceptions.InsufficientDataError(characteristic: str, data: bytes | bytearray, required: int)¶
Bases:
DataParsingErrorException raised when there is insufficient data for parsing.
- actual¶
- required¶
- exception src.bluetooth_sig.gatt.exceptions.MissingDependencyError(characteristic: str, missing_dependencies: list[str])¶
Bases:
CharacteristicErrorException raised when a required dependency is missing for multi-characteristic parsing.
- characteristic¶
- missing_dependencies¶
- exception src.bluetooth_sig.gatt.exceptions.ParseFieldError(characteristic: str, field: str, data: bytes | bytearray, reason: str, offset: int | None = None)¶
Bases:
DataParsingErrorException raised when a specific field fails to parse.
This exception provides detailed context about which field failed, where it failed in the data, and why it failed. This enables actionable error messages and structured error reporting.
NOTE: This exception intentionally has more arguments than the standard limit to provide complete field-level diagnostic information. The additional parameters (field, offset) are essential for actionable error messages and field-level debugging.
- field¶
Name of the field that failed (e.g., “temperature”, “flags”)
- offset¶
Byte offset where the field starts in the raw data
- expected¶
Description of what was expected
- actual¶
Description of what was actually encountered
- field¶
- field_reason¶
- offset = None¶
- exception src.bluetooth_sig.gatt.exceptions.ServiceCharacteristicMismatchError(service: str, missing_characteristics: list[str])¶
Bases:
ServiceErrorException raised when expected characteristics are not found in a service.
service.
- missing_characteristics¶
- service¶
- exception src.bluetooth_sig.gatt.exceptions.ServiceError¶
Bases:
BluetoothSIGErrorBase exception for service-related errors.
- exception src.bluetooth_sig.gatt.exceptions.SpecialValueDetected(special_value: src.bluetooth_sig.types.SpecialValueResult, name: str, uuid: src.bluetooth_sig.types.uuid.BluetoothUUID, raw_data: bytes, raw_int: int | None = None)¶
Bases:
CharacteristicErrorRaised when a special sentinel value is detected.
Special values represent exceptional conditions: “value is not known”, “NaN”, “measurement not possible”, etc. These are semantically distinct from parse failures.
This exception is raised when a valid parse detects a special sentinel value (e.g., 0x8000 = “value is not known”, 0x7FFFFFFF = “NaN”). The parsing succeeded, but the result indicates an exceptional state rather than a normal value.
Most code should catch this separately from CharacteristicParseError to distinguish: - Parse failure (malformed data, wrong length, invalid format) - Special value detection (well-formed data indicating exceptional state)
- special_value¶
The detected special value with meaning and raw bytes
- name¶
Characteristic name
- uuid¶
Characteristic UUID
- raw_data¶
Raw bytes containing the special value
- raw_int¶
The raw integer value (typically the sentinel value)
- name¶
- raw_data¶
- raw_int = None¶
- special_value¶
- uuid¶
- exception src.bluetooth_sig.gatt.exceptions.TemplateConfigurationError(template: str, configuration_issue: str)¶
Bases:
CharacteristicErrorException raised when a template is incorrectly configured.
- configuration_issue¶
- template¶
- exception src.bluetooth_sig.gatt.exceptions.TypeMismatchError(field: str, value: Any, expected_type: type | tuple[type, Ellipsis])¶
Bases:
DataValidationErrorException raised when a value has an unexpected type.
- exception src.bluetooth_sig.gatt.exceptions.UUIDCollisionError(uuid: src.bluetooth_sig.types.uuid.BluetoothUUID | str, existing_name: str, class_name: str)¶
Bases:
BluetoothSIGErrorException raised when attempting to use a UUID that already exists in SIG registry.
- class_name¶
- existing_name¶
- uuid¶
- exception src.bluetooth_sig.gatt.exceptions.UUIDRequiredError(class_name: str, entity_type: str)¶
Bases:
BluetoothSIGErrorException raised when a UUID is required but not provided or invalid.
- class_name¶
- entity_type¶
- exception src.bluetooth_sig.gatt.exceptions.UUIDResolutionError(name: str, attempted_names: list[str] | None = None)¶
Bases:
BluetoothSIGErrorException raised when UUID resolution fails.
- attempted_names = []¶
- name¶
- exception src.bluetooth_sig.gatt.exceptions.ValueRangeError(field: str, value: Any, min_val: Any, max_val: Any)¶
Bases:
DataValidationErrorException raised when a value is outside the expected range.
- max_val¶
- min_val¶