summaryrefslogtreecommitdiffstats
path: root/mail/examples/mail_from_template/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mail/examples/mail_from_template/error.rs')
-rw-r--r--mail/examples/mail_from_template/error.rs56
1 files changed, 56 insertions, 0 deletions
diff --git a/mail/examples/mail_from_template/error.rs b/mail/examples/mail_from_template/error.rs
new file mode 100644
index 0000000..21bccfe
--- /dev/null
+++ b/mail/examples/mail_from_template/error.rs
@@ -0,0 +1,56 @@
+
+use mail::error::{CompositionError, ComponentCreationError};
+use mail::render_template_engine::error::{CreatingSpecError, InsertionError as _InsertionError};
+use mail::tera::error::TeraError;
+
+type InsertionError = _InsertionError<TeraError>;
+
+#[derive(Fail, Debug)]
+pub enum SetupError {
+ #[fail(display = "{}", _0)]
+ Tera(TeraError),
+
+ #[fail(display = "{}", _0)]
+ CreatingSpecs(CreatingSpecError),
+
+ #[fail(display = "{}", _0)]
+ UsingSpecs(InsertionError)
+}
+
+impl From<TeraError> for SetupError {
+ fn from(err: TeraError) -> Self {
+ SetupError::Tera(err)
+ }
+}
+impl From<InsertionError> for SetupError {
+ fn from(err: InsertionError) -> Self {
+ SetupError::UsingSpecs(err)
+ }
+}
+
+impl From<CreatingSpecError> for SetupError {
+ fn from(err: CreatingSpecError) -> Self {
+ SetupError::CreatingSpecs(err)
+ }
+}
+
+// TODO `Header` should be mergeable into `Composition`.
+#[derive(Fail, Debug)]
+pub enum Error {
+ #[fail(display = "{}", _0)]
+ Composition(CompositionError<TeraError>),
+ #[fail(display = "{}", _0)]
+ Header(ComponentCreationError)
+}
+
+impl From<CompositionError<TeraError>> for Error {
+ fn from(err: CompositionError<TeraError>) -> Self {
+ Error::Composition(err)
+ }
+}
+
+impl From<ComponentCreationError> for Error {
+ fn from(err: ComponentCreationError) -> Self {
+ Error::Header(err)
+ }
+}