From a76e332b91a63c0f6929fe3d096c16a7ca56f700 Mon Sep 17 00:00:00 2001 From: Betty Da Date: Wed, 4 Aug 2021 19:54:42 -0400 Subject: [PATCH] don't provide both a source and embed it into the Display impl --- crates/symbolicator/src/services/download/mod.rs | 16 +++++++++++++--- .../src/services/objects/data_cache.rs | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/symbolicator/src/services/download/mod.rs b/crates/symbolicator/src/services/download/mod.rs index 6d27a0461..03ea38d09 100644 --- a/crates/symbolicator/src/services/download/mod.rs +++ b/crates/symbolicator/src/services/download/mod.rs @@ -46,11 +46,10 @@ pub enum DownloadError { Write(#[source] std::io::Error), #[error("download was cancelled")] Canceled, - #[error("failed to fetch data from GCS: {0}")] + #[error("failed to fetch data from GCS")] Gcs(#[from] gcs::GcsError), - #[error("failed to fetch data from Sentry: {0}")] + #[error("failed to fetch data from Sentry")] Sentry(#[from] sentry::SentryError), - #[allow(unused)] #[error("failed to fetch data from S3")] S3(#[from] s3::S3Error), /// Typically means the initial HEAD request received a non-200, non-400 response. @@ -59,6 +58,17 @@ pub enum DownloadError { Rejected(StatusCode), } +impl DownloadError { + pub fn for_cache(&self) -> String { + match self { + DownloadError::Gcs(inner) => format!("{}: {}", self, inner), + DownloadError::Sentry(inner) => format!("{}: {}", self, inner), + DownloadError::S3(inner) => format!("{}: {}", self, inner), + _ => format!("{}", self), + } + } +} + /// Completion status of a successful download request. #[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum DownloadStatus { diff --git a/crates/symbolicator/src/services/objects/data_cache.rs b/crates/symbolicator/src/services/objects/data_cache.rs index a88ac5534..bffb89306 100644 --- a/crates/symbolicator/src/services/objects/data_cache.rs +++ b/crates/symbolicator/src/services/objects/data_cache.rs @@ -169,7 +169,7 @@ impl CacheItemRequest for FetchFileDataRequest { Err(e) => { log::error!("Error while downloading file: {}", LogError(&e)); - return Ok(CacheStatus::Malformed(e.to_string())); + return Ok(CacheStatus::Malformed(e.for_cache())); } Ok(DownloadStatus::Completed) => {