summaryrefslogtreecommitdiffstats
path: root/src/endpoint/error.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-12-10 11:39:30 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-12-10 11:39:30 +0100
commit368d43485d6c888a23afe51743dd6026363238dc (patch)
treec06d924c36354c2c409072f7f708931c98339476 /src/endpoint/error.rs
parent7ddbb6dc627e0086eb1da25278ee29922aa88473 (diff)
Rewrite container error reporting
This patch rewrites the container error reporting to be more simple. The ContainerError type was rewritten to not wrap other errors anymore, but be the root error itself. It only has one variant now, because there's only one kind of error: "It didn't work". The reporting in the calling functions can now use anyhow::Result<_> instead of std::result::Result because of that. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/endpoint/error.rs')
-rw-r--r--src/endpoint/error.rs30
1 files changed, 1 insertions, 29 deletions
diff --git a/src/endpoint/error.rs b/src/endpoint/error.rs
index dc4468a..5638efe 100644
--- a/src/endpoint/error.rs
+++ b/src/endpoint/error.rs
@@ -4,44 +4,16 @@ use crate::util::docker::ContainerHash;
#[derive(ThisError, Debug)]
pub enum ContainerError {
-
- #[error("Error during container run: {container_id}")]
+ #[error("Error during container run, connect using `docker --host {uri} exec -it {container_id} /bin/bash`")]
ContainerError {
container_id: ContainerHash,
uri: String,
},
-
- #[error("{0}")]
- Err(anyhow::Error),
}
impl ContainerError {
pub fn container_error(container_id: ContainerHash, uri: String) -> Self {
ContainerError::ContainerError { container_id, uri }
}
-
- pub fn explain_container_error(&self) -> Option<String> {
- match self {
- ContainerError::ContainerError { container_id, uri } => Some({
- indoc::formatdoc!(r#"
- Container did not exit successfully: {container_id}
- It was not stopped because of this.
-
- Use
-
- docker --host {uri} exec -it {container_id} /bin/bash
-
- to access and debug.
- "#, uri = uri, container_id = container_id)
- }),
- _ => None,
- }
- }
-}
-
-impl From<anyhow::Error> for ContainerError {
- fn from(ae: anyhow::Error) -> Self {
- ContainerError::Err(ae)
- }
}