1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum URError {
5 #[error("UR decoder error ({0})")]
6 UR(ur::ur::Error),
7 #[error("CBOR error ({0})")]
8 Cbor(dcbor::CBORError),
9 #[error("invalid UR scheme")]
10 InvalidScheme,
11 #[error("no UR type specified")]
12 TypeUnspecified,
13 #[error("invalid UR type")]
14 InvalidType,
15 #[error("UR is not a single-part")]
16 NotSinglePart,
17 #[error("expected UR type {0}, but found {1}")]
18 UnexpectedType(String, String),
19}
20
21impl From<ur::ur::Error> for URError {
22 fn from(err: ur::ur::Error) -> Self {
23 URError::UR(err)
24 }
25}
26
27impl From<dcbor::CBORError> for URError {
28 fn from(err: dcbor::CBORError) -> Self {
29 URError::Cbor(err)
30 }
31}