bc_ur/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use thiserror::Error;

#[derive(Debug, Error)]
pub enum URError {
    #[error("UR decoder error ({0})")]
    UR(ur::ur::Error),
    #[error("CBOR error ({0})")]
    Cbor(dcbor::CBORError),
    #[error("invalid UR scheme")]
    InvalidScheme,
    #[error("no UR type specified")]
    TypeUnspecified,
    #[error("invalid UR type")]
    InvalidType,
    #[error("UR is not a single-part")]
    NotSinglePart,
    #[error("expected UR type {0}, but found {1}")]
    UnexpectedType(String, String),
}

impl From<ur::ur::Error> for URError {
    fn from(err: ur::ur::Error) -> Self {
        URError::UR(err)
    }
}

impl From<dcbor::CBORError> for URError {
    fn from(err: dcbor::CBORError) -> Self {
        URError::Cbor(err)
    }
}