diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-12-14 09:10:15 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-12-14 09:10:15 +0100 |
commit | 5be24ff0feb2df70f6d4966407c61a82da2071be (patch) | |
tree | 4420403ee226bbffa97580ef67a288cbdc82ed02 /src/endpoint | |
parent | 0634952adde51f2f6a2ed8e4faa9ffee63f2bb3a (diff) |
Remove ContainerError type, thiserror dependency
This removes the ContainerError type for simplicity. We can call
anyhow!() and just work with that, no need to pull in thiserror just for
one type.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/endpoint')
-rw-r--r-- | src/endpoint/configured.rs | 10 | ||||
-rw-r--r-- | src/endpoint/error.rs | 20 | ||||
-rw-r--r-- | src/endpoint/mod.rs | 3 |
3 files changed, 7 insertions, 26 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs index fdc9f92..2c72b9b 100644 --- a/src/endpoint/configured.rs +++ b/src/endpoint/configured.rs @@ -2,6 +2,7 @@ use std::fmt::{Debug, Formatter}; use std::path::PathBuf; use std::str::FromStr; use std::sync::Arc; +use std::ops::Deref; use anyhow::Context; use anyhow::Error; @@ -17,7 +18,6 @@ use tokio::sync::RwLock; use tokio::sync::mpsc::UnboundedSender; use typed_builder::TypedBuilder; -use crate::endpoint::ContainerError; use crate::endpoint::EndpointConfiguration; use crate::filestore::path::ArtifactPath; use crate::filestore::StagingStore; @@ -382,10 +382,14 @@ impl Endpoint { match exited_successfully { Some((false, msg)) => { let conthash = ContainerHash::from(container_id); - let conterr = ContainerError::container_error(conthash.clone(), self.uri().clone(), msg.unwrap_or_else(|| String::new())); + let err = anyhow!("Error during container run:\n\tMessage: '{msg}'\n\tConnect using\n\n\t\t`docker --host {uri} exec -it {container_id} /bin/bash`\n\n\tto debug.", + container_id = &conthash, + uri = self.uri(), + msg = msg.as_ref().map(String::deref).unwrap_or(""), + ); // error because the container errored - let conterr = Err(conterr).map_err(Error::from); + let conterr = Err(Error::from(err)); // Ok because the general process worked. Ok((conterr, conthash, script)) diff --git a/src/endpoint/error.rs b/src/endpoint/error.rs deleted file mode 100644 index 5c0205c..0000000 --- a/src/endpoint/error.rs +++ /dev/null @@ -1,20 +0,0 @@ -use thiserror::Error as ThisError; - -use crate::util::docker::ContainerHash; - -#[derive(ThisError, Debug)] -pub enum ContainerError { - #[error("Error during container run:\n\tMessage: '{msg}'\n\tConnect using\n\n\t\t`docker --host {uri} exec -it {container_id} /bin/bash`\n\n\tto debug.")] - ContainerError { - container_id: ContainerHash, - uri: String, - msg: String, - }, -} - -impl ContainerError { - pub fn container_error(container_id: ContainerHash, uri: String, msg: String) -> Self { - ContainerError::ContainerError { container_id, uri, msg } - } -} - diff --git a/src/endpoint/mod.rs b/src/endpoint/mod.rs index c66e52f..316a8f3 100644 --- a/src/endpoint/mod.rs +++ b/src/endpoint/mod.rs @@ -1,9 +1,6 @@ mod configuration; pub use configuration::*; -mod error; -pub use error::*; - mod scheduler; pub use scheduler::*; |