diff --git a/libimaglink/src/error.rs b/libimaglink/src/error.rs index a57bbbd9..9dfa7533 100644 --- a/libimaglink/src/error.rs +++ b/libimaglink/src/error.rs @@ -11,6 +11,7 @@ pub enum LinkErrorKind { ExistingLinkTypeWrong, LinkTargetDoesNotExist, InternalConversionError, + InvalidUri, } fn link_error_type_as_str(e: &LinkErrorKind) -> &'static str { @@ -29,6 +30,9 @@ fn link_error_type_as_str(e: &LinkErrorKind) -> &'static str { &LinkErrorKind::InternalConversionError => "Error while converting values internally", + + &LinkErrorKind::InvalidUri + => "URI is not valid", } } diff --git a/libimaglink/src/external.rs b/libimaglink/src/external.rs index 59d6c0e1..4b5ff81c 100644 --- a/libimaglink/src/external.rs +++ b/libimaglink/src/external.rs @@ -100,6 +100,10 @@ impl ExternalLinker for EntryHeader { /// /// Return the previous set link if there was any fn set_external_link(&mut self, l: Link) -> Result> { + if !l.is_valid() { + return Err(LinkError::new(LinkErrorKind::InvalidUri, None)); + } + let old_link = self.set("imag.content.uri", Value::String(l.into())); if old_link.is_err() {