Skip to main content

xrpl/core/keypairs/
exceptions.rs

1//! XRPL keypair codec exceptions.
2
3use thiserror_no_std::Error;
4
5use crate::constants::CryptoAlgorithm;
6use crate::core::addresscodec::exceptions::XRPLAddressCodecException;
7
8#[derive(Debug, PartialEq, Error)]
9#[non_exhaustive]
10pub enum XRPLKeypairsException {
11    #[error("Invalid signature")]
12    InvalidSignature,
13    #[error("Invalid secret")]
14    InvalidSecret,
15    #[error("Unsupported validator algorithm: {expected:?}")]
16    UnsupportedValidatorAlgorithm { expected: CryptoAlgorithm },
17    #[error("ed25519 error")]
18    ED25519Error,
19    #[error("secp256k1 error: {0:?}")]
20    SECP256K1Error(#[from] secp256k1::Error),
21    #[error("XRPL Address codec error: {0}")]
22    XRPLAddressCodecError(XRPLAddressCodecException),
23}
24
25impl From<XRPLAddressCodecException> for XRPLKeypairsException {
26    fn from(err: XRPLAddressCodecException) -> Self {
27        XRPLKeypairsException::XRPLAddressCodecError(err)
28    }
29}
30
31impl From<ed25519_dalek::ed25519::Error> for XRPLKeypairsException {
32    fn from(_: ed25519_dalek::ed25519::Error) -> Self {
33        XRPLKeypairsException::ED25519Error
34    }
35}
36
37#[cfg(feature = "std")]
38impl alloc::error::Error for XRPLKeypairsException {}