use serde::{Deserialize, Serialize};
use thiserror::Error;
#[derive(Clone, Debug, Eq, Error, PartialEq, Deserialize, Serialize)]
pub enum LedgerAppError<E: std::error::Error> {
#[error("This version is not supported")]
InvalidVersion,
#[error("message cannot be empty")]
InvalidEmptyMessage,
#[error("The chunk payload type was invalid. First message should be Init")]
InvalidChunkPayloadType,
#[error("message size is invalid (too big)")]
InvalidMessageSize,
#[error("received an invalid PK")]
InvalidPK,
#[error("received no signature back")]
NoSignature,
#[error("received an invalid signature")]
InvalidSignature,
#[error("invalid derivation path")]
InvalidDerivationPath,
#[error("Transport | {0}")]
TransportError(#[from] E),
#[error("Crypto")]
Crypto,
#[error("Utf8 conversion error")]
Utf8,
#[error("response format ID not recognized")]
InvalidFormatID,
#[error("Couldn't encode string to HEX")]
HexEncode,
#[error("App Error: | {0} {1}")]
AppSpecific(u16, String),
#[error("Unknown error: {0}")]
Unknown(u16),
}