Closed antazoey closed 2 years ago
I spent some time on this trying to translate exceptions:
But there are still a bunch of gaps, like when trying to init the dongle. For example:
ledgerblue.commException.CommException: Exception : No dongle found
It's still somewhat clear, but maybe all exceptions should be from this library and not its dependencies. Do you have any specific gripes you've run into?
I have noticed that if I don't have the Ethereum app open, it will also complain about not finding the dongle.
Here is how we are handling this in ape-ledger
. It is not perfect but gives a few scenarios:
https://github.com/ApeWorX/ape-ledger/blob/main/ape_ledger/client.py#L173-L179
Here is a response verification we do: https://github.com/ApeWorX/ape-ledger/blob/main/ape_ledger/client.py#L173-L179
Also here is our comms error mapping: https://github.com/ApeWorX/ape-ledger/blob/main/ape_ledger/client.py#L68-L82
Timeout is also nice to have: https://github.com/ApeWorX/ape-ledger/blob/main/ape_ledger/exceptions.py#L23
Also, when trying to sign an unknown message type: https://github.com/ApeWorX/ape-ledger/blob/main/ape_ledger/accounts.py#L86
Used a bunch of your error defs and pulled a few from the app-ethereum source. Added some better exceptions and handling in PR #23. Since you raised this issue, I would appreciate your thoughts on the changes at your leisure.
The error experience when not properly connected to a device could be improved.
Another case would be to explore errors for not having the app installed and making APDU specific errors come out okay.