diff --git a/flare/src/hub.rs b/flare/src/hub.rs index 13e45ec79..0d664eb60 100644 --- a/flare/src/hub.rs +++ b/flare/src/hub.rs @@ -3395,13 +3395,50 @@ fn resolve_revision( Ok(info) } +#[derive(Debug)] +struct RevisionLookupError { + repository: String, + revision: String, + source: Box, +} + +impl std::fmt::Display for RevisionLookupError { + fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!( + formatter, + "cannot resolve {}@{}: {}", + self.repository, self.revision, self.source + ) + } +} + +impl std::error::Error for RevisionLookupError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + Some(self.source.as_ref()) + } +} + fn resolve_primary_target( api: &Api, repo: &Repo, requested: Option<&str>, progress: Option<&flare_helios::core::progress::AcquisitionProgress>, ) -> Result<(Repo, String)> { - let info = resolve_revision(api, repo, progress)?; + let info = resolve_revision(api, repo, progress).map_err(|source| { + if matches!( + source.downcast_ref::(), + Some(ApiError::RequestError(error)) + if matches!(error.as_ref(), ureq::Error::StatusCode(404)) + ) { + Box::new(RevisionLookupError { + repository: repo.url(), + revision: repo.revision().to_owned(), + source, + }) + } else { + source + } + })?; let filename = choose_file( info.siblings.into_iter().map(|file| file.rfilename), requested, @@ -8580,6 +8617,9 @@ pub(crate) mod tests { .to_string(); worker.join().unwrap(); assert!(error.contains(&status.to_string()), "{error}"); + if status == 404 { + assert!(error.contains(&format!("owner/model@{revision}")), "{error}"); + } assert_eq!(log.lock().unwrap().documents[&route], 1); } }