Skip to main content

ledger_sdk_device_base/
errors.rs

1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// App Error
5#[derive(Clone, Debug, Eq, Error, PartialEq, Deserialize, Serialize)]
6pub enum LedgerAppError<E: std::error::Error> {
7    /// Invalid version error
8    #[error("This version is not supported")]
9    InvalidVersion,
10    /// The message cannot be empty
11    #[error("message cannot be empty")]
12    InvalidEmptyMessage,
13    /// Invalid payload type in chunk
14    #[error("The chunk payload type was invalid. First message should be Init")]
15    InvalidChunkPayloadType,
16    /// The size fo the message to sign is invalid
17    #[error("message size is invalid (too big)")]
18    InvalidMessageSize,
19    /// Public Key is invalid
20    #[error("received an invalid PK")]
21    InvalidPK,
22    /// No signature has been returned
23    #[error("received no signature back")]
24    NoSignature,
25    /// The signature is not valid
26    #[error("received an invalid signature")]
27    InvalidSignature,
28    /// The derivation is invalid
29    #[error("invalid derivation path")]
30    InvalidDerivationPath,
31    /// The derivation is invalid
32    #[error("Transport | {0}")]
33    TransportError(#[from] E),
34    /// Crypto related errors
35    #[error("Crypto")]
36    Crypto,
37    /// Utf8 related errors
38    #[error("Utf8 conversion error")]
39    Utf8,
40    /// Format ID error
41    #[error("response format ID not recognized")]
42    InvalidFormatID,
43    /// HexEncode
44    #[error("Couldn't encode string to HEX")]
45    HexEncode,
46    /// Application specific error
47    #[error("App Error: | {0} {1}")]
48    AppSpecific(u16, String),
49    ///Unknown error has occurred
50    #[error("Unknown error: {0}")]
51    Unknown(u16),
52}