Commit bab4efb2 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

file: Always return glib::Error with domain gst::URIError from set_uri()

parent e77c2335
......@@ -49,14 +49,14 @@ impl FileLocation {
fn try_from(location: PathBuf) -> Result<Self, glib::Error> {
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(),
)
})
......
......@@ -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",
));
}
......
......@@ -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(),
));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment