diff --git a/src/ur_decodable.rs b/src/ur_decodable.rs index b8cc688..d8496e9 100644 --- a/src/ur_decodable.rs +++ b/src/ur_decodable.rs @@ -7,8 +7,13 @@ use dcbor::CBORTaggedDecodable; /// A type that can be decoded from a UR. pub trait URDecodable: CBORTaggedDecodable { fn from_ur(ur: impl AsRef) -> Result where Self: Sized { - ur.as_ref().check_type(Self::cbor_tags()[0].name().as_ref().unwrap().clone())?; - Self::from_untagged_cbor(ur.as_ref().clone().into()) + let tag = &Self::cbor_tags()[0]; + if let Some(name) = tag.name().as_ref() { + ur.as_ref().check_type(name.clone())?; + Self::from_untagged_cbor(ur.as_ref().clone().into()) + } else { + panic!("CBOR tag {} must have a name. Did you call `register_tags()`?", tag.value()); + } } fn from_ur_string(ur_string: impl Into) -> Result where Self: Sized {