aboutsummaryrefslogtreecommitdiff
path: root/development/tools/cargo-workspace2/src/ops/error.rs
diff options
context:
space:
mode:
Diffstat (limited to 'development/tools/cargo-workspace2/src/ops/error.rs')
-rw-r--r--development/tools/cargo-workspace2/src/ops/error.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/development/tools/cargo-workspace2/src/ops/error.rs b/development/tools/cargo-workspace2/src/ops/error.rs
new file mode 100644
index 000000000000..3dde73d954d8
--- /dev/null
+++ b/development/tools/cargo-workspace2/src/ops/error.rs
@@ -0,0 +1,28 @@
+use std::fmt::{self, Display, Formatter};
+
+/// Special result type that wraps an OpError
+pub type Result<T> = std::result::Result<T, OpError>;
+
+/// An error that occured while running an operation
+#[derive(Debug)]
+pub enum OpError {
+ NoSuchCrate(String),
+ CircularDependency(String, String),
+}
+
+impl Display for OpError {
+ fn fmt(&self, f: &mut Formatter) -> fmt::Result {
+ write!(
+ f,
+ "{}",
+ match self {
+ Self::NoSuchCrate(n) => format!("No crate `{}` was not found in the workspace", n),
+ Self::CircularDependency(a, b) => format!(
+ "Crates `{}` and `{}` share a hard circular dependency.\
+ Operation not possible!",
+ a, b
+ ),
+ }
+ )
+ }
+}