mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-03-07 02:36:06 +00:00
docs(python): document trezorlib exception classes
This commit is contained in:
parent
cb0aef9a4c
commit
9862bc7123
@ -24,10 +24,15 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
|
|
||||||
class TrezorException(Exception):
|
class TrezorException(Exception):
|
||||||
pass
|
"""General Trezor exception."""
|
||||||
|
|
||||||
|
|
||||||
class TrezorFailure(TrezorException):
|
class TrezorFailure(TrezorException):
|
||||||
|
"""Failure received over the wire from Trezor.
|
||||||
|
|
||||||
|
Corresponds to a `Failure` protobuf message.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, failure: Failure) -> None:
|
def __init__(self, failure: Failure) -> None:
|
||||||
self.failure = failure
|
self.failure = failure
|
||||||
self.code = failure.code
|
self.code = failure.code
|
||||||
@ -49,18 +54,33 @@ class TrezorFailure(TrezorException):
|
|||||||
|
|
||||||
|
|
||||||
class PinException(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):
|
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):
|
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):
|
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:
|
def __init__(self, expected: type[MessageType], actual: MessageType) -> None:
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
self.actual = actual
|
self.actual = actual
|
||||||
|
Loading…
Reference in New Issue
Block a user