aboutsummaryrefslogtreecommitdiff
path: root/src/errors/injectable.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-08-21 14:19:07 +0200
committerHampusM <hampus@hampusmat.com>2022-08-21 18:17:51 +0200
commit8c66b98bca6ed0a2990903fe8e0ea72def5c7be8 (patch)
treedeed78171051262dba7e8d97eba73a9aaf04dd5e /src/errors/injectable.rs
parentb3e1b993b028bbfa73638236cfbdb50ee478d3f0 (diff)
refactor!: change errors to be more sane
BREAKING CHANGE: Major improvements have been made to error types and the error_stack crate is no longer used
Diffstat (limited to 'src/errors/injectable.rs')
-rw-r--r--src/errors/injectable.rs41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/errors/injectable.rs b/src/errors/injectable.rs
index 63afa11..4b9af96 100644
--- a/src/errors/injectable.rs
+++ b/src/errors/injectable.rs
@@ -1,20 +1,33 @@
-//! Error types for structs implementing Injectable.
+#![allow(clippy::module_name_repetitions)]
+//! Error types for structs that implement [`Injectable`].
+//!
+//! [`Injectable`]: crate::interfaces::injectable::Injectable
-use core::fmt;
-use std::fmt::{Display, Formatter};
+use super::di_container::DIContainerError;
-use error_stack::Context;
+/// Error type for structs that implement [`Injectable`].
+///
+/// [`Injectable`]: crate::interfaces::injectable::Injectable
+#[derive(thiserror::Error, Debug)]
+pub enum InjectableError
+{
+ /// Failed to resolve dependencies.
+ #[error("Failed to resolve a dependency of '{affected}'")]
+ ResolveFailed
+ {
+ /// The reason for the problem.
+ #[source]
+ reason: Box<DIContainerError>,
-/// Error for when a injectable struct fails to be resolved.
-#[derive(Debug)]
-pub struct ResolveError;
+ /// The affected injectable type.
+ affected: &'static str,
+ },
-impl Display for ResolveError
-{
- fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result
+ /// Detected circular dependencies.
+ #[error("Detected circular dependencies. {dependency_trace}")]
+ DetectedCircular
{
- fmt.write_str("Failed to resolve injectable struct")
- }
+ /// A visual trace of dependencies.
+ dependency_trace: String,
+ },
}
-
-impl Context for ResolveError {}