Errors¶
All error classes are importable from pykeyboard.
Hierarchy¶
classDiagram
direction LR
Exception <|-- PyKeyboardError
PyKeyboardError <|-- ValidationError
PyKeyboardError <|-- PaginationError
PaginationError <|-- PaginationUnchangedError
PyKeyboardError <|-- LocaleError
PyKeyboardError <|-- ConfigurationError PyKeyboardError Base¶
Base class for all PyKeyboard errors. Catch this to handle any library error.
PyKeyboardError(
message: str,
error_code: str = "PYKEYBOARD_ERROR",
param: str = "",
value: Any = None,
reason: str = "",
)
Common Attributes¶
| Attribute | Type | Description |
|---|---|---|
error_code | str | Stable identifier, e.g. "VALIDATION_ERROR" |
message | str | Human-readable description |
param | str | Parameter that caused the error |
value | Any | The invalid value |
reason | str | Additional context |
Tip
Use error_code for programmatic handling. Use str(e) for user-facing messages — it returns a clean, multi-line formatted string.
ValidationError Class¶
Raised when button or keyboard input fails validation.
Error code: VALIDATION_ERROR
Example
PaginationError Class¶
Raised when pagination parameters are invalid.
Error code: PAGINATION_ERROR
Example
PaginationUnchangedError Class¶
Raised when an identical pagination keyboard was already generated (duplicate prevention).
Error code: PAGINATION_UNCHANGED Inherits: PaginationError
Example
LocaleError Class¶
Raised when locale parameters are invalid.
Error code: LOCALE_ERROR
ConfigurationError Class¶
Raised when keyboard configuration is invalid.
Error code: CONFIGURATION_ERROR