diff --git a/Cargo.toml b/Cargo.toml index 95ab623..f8a21aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,3 +15,4 @@ gstreamer = "0.16.2" gstreamer-app = "0.16.0" gstreamer-video = "0.16.0" log = "0.4" +thiserror = "1" diff --git a/src/file.rs b/src/file.rs index 4fe0833..0251e90 100644 --- a/src/file.rs +++ b/src/file.rs @@ -38,13 +38,8 @@ impl IntoIterator for FileSource { } } -#[derive(Debug)] +#[derive(Debug, thiserror::Error)] pub enum CaptureError { - IoError(io::Error), -} - -impl From for CaptureError { - fn from(err: io::Error) -> Self { - CaptureError::IoError(err) - } + #[error("IO error: {0}")] + IoError(#[from] io::Error), } diff --git a/src/video_stream.rs b/src/video_stream.rs index 9016448..11d17cc 100644 --- a/src/video_stream.rs +++ b/src/video_stream.rs @@ -33,9 +33,11 @@ pub struct GstErrorMessage { pub source: glib::Error, } -#[derive(Debug)] +#[derive(Debug, thiserror::Error)] pub enum StreamError { + #[error("GST error: {0:?}")] GstError(GstErrorMessage), + #[error("frame capture error")] FrameCaptureError, }