mirror of
https://git.asonix.dog/asonix/pict-rs
synced 2024-11-20 11:21:14 +00:00
35 lines
987 B
Rust
35 lines
987 B
Rust
use crate::{error_code::ErrorCode, process::ProcessError};
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub(crate) enum ExifError {
|
|
#[error("Error in process")]
|
|
Process(#[source] ProcessError),
|
|
|
|
#[error("Invalid media file provided")]
|
|
CommandFailed(ProcessError),
|
|
}
|
|
|
|
impl From<ProcessError> for ExifError {
|
|
fn from(value: ProcessError) -> Self {
|
|
match value {
|
|
e @ ProcessError::Status(_, _) => Self::CommandFailed(e),
|
|
otherwise => Self::Process(otherwise),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ExifError {
|
|
pub(crate) const fn error_code(&self) -> ErrorCode {
|
|
match self {
|
|
Self::Process(e) => e.error_code(),
|
|
Self::CommandFailed(_) => ErrorCode::COMMAND_FAILURE,
|
|
}
|
|
}
|
|
pub(crate) fn is_client_error(&self) -> bool {
|
|
// if exiftool bails we probably have bad input
|
|
match self {
|
|
Self::CommandFailed(_) => true,
|
|
Self::Process(e) => e.is_client_error(),
|
|
}
|
|
}
|
|
}
|