Refactor: Extract new crate binstalk-fetchers (#1291)

To reduce `binstalk` codegen and enable better reuse.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-08-14 13:20:34 +10:00 committed by GitHub
parent 623f7ff4ed
commit 76c72469eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1008 additions and 122 deletions

View file

@ -7,6 +7,7 @@ use std::{
use binstalk_downloader::{
download::DownloadError, gh_api_client::GhApiError, remote::Error as RemoteError,
};
use binstalk_fetchers::FetchError;
use compact_str::CompactString;
use miette::{Diagnostic, Report};
use target_lexicon::ParseError as TargetTripleParseError;
@ -94,6 +95,16 @@ pub enum BinstallError {
leon::ParseError,
),
/// Failed to fetch pre-built binaries.
///
/// - Code: `binstall::fetch`
/// - Exit: 68
#[error(transparent)]
#[diagnostic(severity(error), code(binstall::fetch))]
#[source_code(transparent)]
#[label(transparent)]
FetchError(Box<FetchError>),
/// Failed to render template.
///
/// - Code: `binstall::template`
@ -352,6 +363,7 @@ impl BinstallError {
UserAbort => 32,
UrlParse(_) => 65,
TemplateParseError(..) => 67,
FetchError(..) => 68,
TemplateRenderError(..) => 69,
Download(_) => 68,
SubProcess { .. } => 70,
@ -494,3 +506,9 @@ impl From<LoadManifestFromWSError> for BinstallError {
BinstallError::LoadManifestFromWSError(Box::new(e))
}
}
impl From<FetchError> for BinstallError {
fn from(e: FetchError) -> Self {
BinstallError::FetchError(Box::new(e))
}
}