#[derive(thiserror::Error)]
pub enum ModelError {
#[error("Failed to execute inference request with provided inputs")]
InferenceError(String),
#[error("Failed to build model")]
BuildError(String),
}
#[derive(thiserror::Error)]
pub enum TritonClientError {
#[error("The requested model does not exist on this Triton Server")]
ModelDoesNotExistError(String),
#[error("Failed to build client")]
BuildError(String),
#[error("Unknown error occurred")]
UnknownError(String),
}
impl std::fmt::Debug for ModelError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
error_chain_fmt(self, f)
}
}
impl std::fmt::Debug for TritonClientError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
error_chain_fmt(self, f)
}
}
fn error_chain_fmt(
e: &impl std::error::Error,
f: &mut std::fmt::Formatter<'_>,
) -> std::fmt::Result {
writeln!(f, "{e}\n")?;
let mut current = e.source();
while let Some(cause) = current {
writeln!(f, "Caused by:\n\t{cause}")?;
current = cause.source();
}
Ok(())
}