35 lines
899 B
Rust
35 lines
899 B
Rust
|
use std::{fmt, io, process};
|
||
|
|
||
|
#[derive(Debug)]
|
||
|
pub enum AnalyzeError {
|
||
|
FFProbeError(FFProbeError),
|
||
|
IOError(io::Error),
|
||
|
ParseError(serde_json::Error),
|
||
|
}
|
||
|
|
||
|
impl fmt::Display for AnalyzeError {
|
||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||
|
match self {
|
||
|
AnalyzeError::FFProbeError(err) => write!(f, "{}", err),
|
||
|
AnalyzeError::IOError(err) => write!(f, "{}", err),
|
||
|
AnalyzeError::ParseError(err) => write!(f, "{}", err),
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#[derive(Debug, Clone)]
|
||
|
pub struct FFProbeError {
|
||
|
pub exit_status: process::ExitStatus,
|
||
|
pub stderr: String,
|
||
|
}
|
||
|
|
||
|
impl fmt::Display for FFProbeError {
|
||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||
|
write!(
|
||
|
f,
|
||
|
"ffprobe exited with error code {}, stderr: {}",
|
||
|
self.exit_status.code().unwrap(),
|
||
|
self.stderr
|
||
|
)
|
||
|
}
|
||
|
}
|