Implement Error for error types (#1)

This commit is contained in:
Matt Fellenz 2022-04-20 14:45:10 -07:00 committed by GitHub
parent a153d2dcce
commit bbf6009c0c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 9 deletions

View file

@ -15,3 +15,4 @@ gstreamer = "0.16.2"
gstreamer-app = "0.16.0" gstreamer-app = "0.16.0"
gstreamer-video = "0.16.0" gstreamer-video = "0.16.0"
log = "0.4" log = "0.4"
thiserror = "1"

View file

@ -38,13 +38,8 @@ impl IntoIterator for FileSource {
} }
} }
#[derive(Debug)] #[derive(Debug, thiserror::Error)]
pub enum CaptureError { pub enum CaptureError {
IoError(io::Error), #[error("IO error: {0}")]
} IoError(#[from] io::Error),
impl From<io::Error> for CaptureError {
fn from(err: io::Error) -> Self {
CaptureError::IoError(err)
}
} }

View file

@ -33,9 +33,11 @@ pub struct GstErrorMessage {
pub source: glib::Error, pub source: glib::Error,
} }
#[derive(Debug)] #[derive(Debug, thiserror::Error)]
pub enum StreamError { pub enum StreamError {
#[error("GST error: {0:?}")]
GstError(GstErrorMessage), GstError(GstErrorMessage),
#[error("frame capture error")]
FrameCaptureError, FrameCaptureError,
} }