diff --git a/python/src/trezorlib/exceptions.py b/python/src/trezorlib/exceptions.py index 99f0048dd3..87c04e7e6e 100644 --- a/python/src/trezorlib/exceptions.py +++ b/python/src/trezorlib/exceptions.py @@ -24,10 +24,15 @@ if TYPE_CHECKING: class TrezorException(Exception): - pass + """General Trezor exception.""" class TrezorFailure(TrezorException): + """Failure received over the wire from Trezor. + + Corresponds to a `Failure` protobuf message. + """ + def __init__(self, failure: Failure) -> None: self.failure = failure self.code = failure.code @@ -49,18 +54,33 @@ class TrezorFailure(TrezorException): class PinException(TrezorException): - pass + """PIN operation has failed. + + This exception is only raised on Trezor Model One. It indicates to the caller that + the Trezor rejected the PIN entered via host-side matrix keyboard. + """ class Cancelled(TrezorException): - pass + """Action was cancelled. + + Cancellation can be either received from Trezor or caused by the library, typically + in response to user action.""" class OutdatedFirmwareError(TrezorException): - pass + """Trezor firmware is too old. + + Raised when interfacing with a Trezor whose firmware version is no longer supported + by current library version.""" class UnexpectedMessageError(TrezorException): + """Unexpected message received from Trezor. + + Raised when the library receives a response from Trezor that does not match the + previous request.""" + def __init__(self, expected: type[MessageType], actual: MessageType) -> None: self.expected = expected self.actual = actual