llm_chain/prompt/string_template/
error.rsuse thiserror::Error;
#[derive(Error, Debug, Clone)]
pub enum StringTemplateErrorImpl {
#[error("Tera error: {0}")]
Tera(String),
#[error("Unable to load file: {0}")]
UnableToLoadFile(String),
#[error("Unable to parse template: {0}")]
LegacyTemplateError(String),
}
impl From<std::io::Error> for StringTemplateErrorImpl {
fn from(error: std::io::Error) -> Self {
StringTemplateErrorImpl::UnableToLoadFile(error.to_string())
}
}
impl From<tera::Error> for StringTemplateErrorImpl {
fn from(error: tera::Error) -> Self {
StringTemplateErrorImpl::Tera(error.to_string())
}
}
#[derive(Error, Debug, Clone)]
#[error(transparent)]
pub struct StringTemplateError(#[from] StringTemplateErrorImpl);