aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/repository
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/repository')
-rw-r--r--crates/shirabe/src/repository/artifact_repository.rs14
-rw-r--r--crates/shirabe/src/repository/composer_repository.rs18
-rw-r--r--crates/shirabe/src/repository/path_repository.rs9
-rw-r--r--crates/shirabe/src/repository/vcs/github_driver.rs18
4 files changed, 34 insertions, 25 deletions
diff --git a/crates/shirabe/src/repository/artifact_repository.rs b/crates/shirabe/src/repository/artifact_repository.rs
index 2d16f137..75ad134b 100644
--- a/crates/shirabe/src/repository/artifact_repository.rs
+++ b/crates/shirabe/src/repository/artifact_repository.rs
@@ -224,11 +224,15 @@ impl ArtifactRepository {
.unwrap_or_default();
match self.loader.load(cfg, None) {
Ok(package) => Ok(Some(package)),
- Err(exception) => Err(UnexpectedValueException::new(format!(
- "Failed loading package in {}: {}",
- pathname, exception
- ))
- .into()),
+ Err(exception) => {
+ let message = format!("Failed loading package in {}: {}", pathname, exception);
+ Err(UnexpectedValueException::with_code_and_previous(
+ message,
+ 0,
+ Some(std::sync::Arc::new(exception)),
+ )
+ .into())
+ }
}
}
}
diff --git a/crates/shirabe/src/repository/composer_repository.rs b/crates/shirabe/src/repository/composer_repository.rs
index 5371c2c3..b53374aa 100644
--- a/crates/shirabe/src/repository/composer_repository.rs
+++ b/crates/shirabe/src/repository/composer_repository.rs
@@ -40,9 +40,9 @@ use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_metadata_minifier::MetadataMinifier;
use shirabe_php_shim::Catch as _;
use shirabe_php_shim::{
- CmpOp, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed, RuntimeException,
- UnexpectedValueException, extension_loaded, hash, http_build_query, json_decode, parse_url_all,
- php_regex, realpath, strtolower, strtr, urlencode, var_export,
+ AnyThrowable, CmpOp, InvalidArgumentException, LogicException, PHP_EOL, PhpMixed,
+ RuntimeException, UnexpectedValueException, extension_loaded, hash, http_build_query,
+ json_decode, parse_url_all, php_regex, realpath, strtolower, strtr, urlencode, var_export,
};
use shirabe_semver::CompilingMatcher;
use shirabe_semver::constraint::AnyConstraint;
@@ -2695,17 +2695,21 @@ impl ComposerRepository {
})();
result.map_err(|e| {
- RuntimeException::new(format!(
+ let message = format!(
"Could not load packages in {}{}: [{}] {}",
self.get_repo_name(),
source
.as_ref()
.map(|s| format!(" from {}", s))
.unwrap_or_default(),
- "Exception",
+ AnyThrowable::of(e.as_ref()).map_or_else(
+ || "Exception".to_string(),
+ shirabe_php_shim::PhpClass::php_class_name,
+ ),
e
- ))
- .into()
+ );
+ RuntimeException::with_code_and_previous(message, 0, Some(std::sync::Arc::new(e)))
+ .into()
})
}
diff --git a/crates/shirabe/src/repository/path_repository.rs b/crates/shirabe/src/repository/path_repository.rs
index 313fc75e..46b7f95f 100644
--- a/crates/shirabe/src/repository/path_repository.rs
+++ b/crates/shirabe/src/repository/path_repository.rs
@@ -350,10 +350,11 @@ impl PathRepository {
self.inner
.add_package(self.loader.load(package.clone(), None).map_err(|e| {
- RuntimeException::new(format!(
- "Failed loading the package in {}",
- composer_file_path
- ))
+ RuntimeException::with_code_and_previous(
+ format!("Failed loading the package in {}", composer_file_path),
+ 0,
+ Some(std::sync::Arc::new(e)),
+ )
})?);
}
diff --git a/crates/shirabe/src/repository/vcs/github_driver.rs b/crates/shirabe/src/repository/vcs/github_driver.rs
index 72bcc8ae..ffdf04ec 100644
--- a/crates/shirabe/src/repository/vcs/github_driver.rs
+++ b/crates/shirabe/src/repository/vcs/github_driver.rs
@@ -1038,7 +1038,7 @@ impl GitHubDriver {
}
if !self.inner.io.is_interactive() {
- self.attempt_clone_fallback(Some(&e))
+ self.attempt_clone_fallback(Some(std::sync::Arc::new((*e).into())))
.map_err(|err| TransportException::new(err.to_string(), 0))?;
return Ok(Response::new(
@@ -1090,7 +1090,7 @@ impl GitHubDriver {
}
if !self.inner.io.is_interactive() && fetching_repo_data {
- self.attempt_clone_fallback(Some(&e))
+ self.attempt_clone_fallback(Some(std::sync::Arc::new((*e).into())))
.map_err(|err| TransportException::new(err.to_string(), 0))?;
return Ok(Response::new(
@@ -1177,7 +1177,7 @@ impl GitHubDriver {
}
Err(e) => {
if e.get_code() == 499 {
- self.attempt_clone_fallback(Some(&e))?;
+ self.attempt_clone_fallback(Some(std::sync::Arc::new((*e).into())))?;
} else {
return Err((*e).into());
}
@@ -1227,14 +1227,14 @@ impl GitHubDriver {
/// @throws \RuntimeException
pub(crate) fn attempt_clone_fallback(
&mut self,
- e: Option<&TransportException>,
+ e: Option<std::sync::Arc<anyhow::Error>>,
) -> anyhow::Result<bool> {
if !self.allow_git_fallback {
- return Err(RuntimeException::new(format!(
- "Fallback to git driver disabled{}",
- e.map(|e| format!(": {}", e.get_message()))
- .unwrap_or_default()
- ))
+ return Err(RuntimeException::with_code_and_previous(
+ "Fallback to git driver disabled".to_string(),
+ 0,
+ e,
+ )
.into());
}