From bab4efb234e523476ba9cabea3520578dc28982c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 30 Dec 2018 12:02:28 +0200 Subject: [PATCH] file: Always return glib::Error with domain gst::URIError from set_uri() --- gst-plugin-file/src/file_location.rs | 8 ++++---- gst-plugin-file/src/filesink.rs | 2 +- gst-plugin-file/src/filesrc.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gst-plugin-file/src/file_location.rs b/gst-plugin-file/src/file_location.rs index 6c085dee..0812e9d8 100644 --- a/gst-plugin-file/src/file_location.rs +++ b/gst-plugin-file/src/file_location.rs @@ -49,14 +49,14 @@ impl FileLocation { fn try_from(location: PathBuf) -> Result { let location_str = location.to_str().ok_or_else(|| { gst::Error::new( - gst::LibraryError::Failed, + gst::URIError::BadReference, format!("Invalid path {:?}", location).as_str(), ) })?; let file_name = location.file_name().ok_or_else(|| { gst::Error::new( - gst::LibraryError::Failed, + gst::URIError::BadReference, format!("Expected a path with a filename, got {}", location_str,).as_str(), ) })?; @@ -75,7 +75,7 @@ impl FileLocation { let parent_canonical = parent_dir.canonicalize().map_err(|err| { gst::Error::new( - gst::LibraryError::Failed, + gst::URIError::BadReference, format!( "Could not resolve path {}: {}", location_str, @@ -106,7 +106,7 @@ impl FileLocation { Url::from_file_path(&location_canonical) .map_err(|_| { gst::Error::new( - gst::LibraryError::Failed, + gst::URIError::BadReference, format!("Could not resolve path to URL {}", location_str).as_str(), ) }) diff --git a/gst-plugin-file/src/filesink.rs b/gst-plugin-file/src/filesink.rs index d6d7df8d..7bed04c9 100644 --- a/gst-plugin-file/src/filesink.rs +++ b/gst-plugin-file/src/filesink.rs @@ -76,7 +76,7 @@ impl FileSink { let state = self.state.lock().unwrap(); if let State::Started { .. } = *state { return Err(gst::Error::new( - gst::LibraryError::Failed, + gst::URIError::BadState, "Changing the `location` property on a started `filesink` is not supported", )); } diff --git a/gst-plugin-file/src/filesrc.rs b/gst-plugin-file/src/filesrc.rs index 60d8e4d1..66e16032 100644 --- a/gst-plugin-file/src/filesrc.rs +++ b/gst-plugin-file/src/filesrc.rs @@ -75,7 +75,7 @@ impl FileSrc { let state = self.state.lock().unwrap(); if let State::Started { .. } = *state { return Err(gst::Error::new( - gst::LibraryError::Failed, + gst::URIError::BadState, "Changing the `location` property on a started `filesrc` is not supported", )); } @@ -85,14 +85,14 @@ impl FileSrc { Some(location) => { if !location.exists() { return Err(gst::Error::new( - gst::LibraryError::Failed, + gst::URIError::BadReference, format!("{} doesn't exist", location).as_str(), )); } if !location.is_file() { return Err(gst::Error::new( - gst::LibraryError::Failed, + gst::URIError::BadReference, format!("{} is not a file", location).as_str(), )); }