llm_chain/prompt/string_template/
error.rs1use thiserror::Error;
2
3#[derive(Error, Debug, Clone)]
4pub enum StringTemplateErrorImpl {
5 #[error("Tera error: {0}")]
6 Tera(String),
7 #[error("Unable to load file: {0}")]
8 UnableToLoadFile(String),
9 #[error("Unable to parse template: {0}")]
10 LegacyTemplateError(String),
11}
12
13impl From<std::io::Error> for StringTemplateErrorImpl {
14 fn from(error: std::io::Error) -> Self {
15 StringTemplateErrorImpl::UnableToLoadFile(error.to_string())
16 }
17}
18
19impl From<tera::Error> for StringTemplateErrorImpl {
20 fn from(error: tera::Error) -> Self {
21 StringTemplateErrorImpl::Tera(error.to_string())
22 }
23}
24
25#[derive(Error, Debug, Clone)]
26#[error(transparent)]
27pub struct StringTemplateError(#[from] StringTemplateErrorImpl);