mirror of
https://github.com/esp-rs/espup.git
synced 2025-09-29 22:01:07 +00:00
refactor: ♻️ Use anyhow::Result in espidf
This commit is contained in:
parent
b4c95c4ec4
commit
d38cbe87f4
@ -59,7 +59,10 @@ pub enum Error {
|
||||
#[diagnostic(code(espup::toolchain::espidf::failed_to_instatiate_cmake))]
|
||||
#[error("{} Failed to add CMake to ESP-IDF tools", emoji::ERROR)]
|
||||
FailedToInstantiateCmake,
|
||||
#[diagnostic(code(espup::toolchain::espidf::failed_to_instatiate_cmake))]
|
||||
#[diagnostic(code(espup::toolchain::espidf::failed_to_create_esp_idf_install_closure))]
|
||||
#[error("{} Failed to create ESP-IDF install closure", emoji::ERROR)]
|
||||
FailedToCreateEspIdfInstallClosure,
|
||||
#[diagnostic(code(espup::toolchain::espidf::failed_to_install_esp_idf))]
|
||||
#[error("{} Failed to install ESP-IDF", emoji::ERROR)]
|
||||
FailedToInstallEspIdf,
|
||||
// Main
|
||||
|
@ -71,8 +71,8 @@ impl EspIdfRepo {
|
||||
|
||||
// A closure to specify which tools `idf-tools.py` should install.
|
||||
let make_tools = move |repo: &git::Repository,
|
||||
version: &Result<espidf::EspIdfVersion>|
|
||||
-> Result<Vec<espidf::Tools>> {
|
||||
version: &anyhow::Result<espidf::EspIdfVersion>|
|
||||
-> anyhow::Result<Vec<espidf::Tools>> {
|
||||
let version_str = match version {
|
||||
Ok(v) => format!("v{v}"),
|
||||
Err(_) => "(unknown version)".to_string(),
|
||||
@ -126,13 +126,14 @@ impl EspIdfRepo {
|
||||
Ok(tools)
|
||||
};
|
||||
|
||||
let install = |esp_idf_origin: espidf::EspIdfOrigin| -> Result<espidf::EspIdf, Error> {
|
||||
espidf::Installer::new(esp_idf_origin)
|
||||
.install_dir(Some(self.install_path.clone()))
|
||||
// .with_tools(make_tools.into())
|
||||
.install()
|
||||
.map_err(|_| Error::FailedToInstallEspIdf)
|
||||
};
|
||||
let install =
|
||||
|esp_idf_origin: espidf::EspIdfOrigin| -> anyhow::Result<espidf::EspIdf, Error> {
|
||||
espidf::Installer::new(esp_idf_origin)
|
||||
.install_dir(Some(self.install_path.clone()))
|
||||
.with_tools(make_tools)
|
||||
.install()
|
||||
.map_err(|_| Error::FailedToCreateEspIdfInstallClosure)
|
||||
};
|
||||
|
||||
let repo = espidf::EspIdfRemote {
|
||||
git_ref: espidf::parse_esp_idf_git_ref(&self.version),
|
||||
|
Loading…
x
Reference in New Issue
Block a user