aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/package
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/package')
-rw-r--r--crates/shirabe/src/package/archiver/phar_archiver.rs6
-rw-r--r--crates/shirabe/src/package/loader/array_loader.rs27
2 files changed, 24 insertions, 9 deletions
diff --git a/crates/shirabe/src/package/archiver/phar_archiver.rs b/crates/shirabe/src/package/archiver/phar_archiver.rs
index 0968f2a4..4a41d5a4 100644
--- a/crates/shirabe/src/package/archiver/phar_archiver.rs
+++ b/crates/shirabe/src/package/archiver/phar_archiver.rs
@@ -5,7 +5,7 @@ use crate::package::archiver::ArchivableFilesFinder;
use crate::package::archiver::ArchiverInterface;
use indexmap::IndexMap;
use shirabe_php_shim::{
- FilesystemIterator, Phar, PharData, RuntimeException, bzcompress, file_exists,
+ AnyThrowable, FilesystemIterator, Phar, PharData, RuntimeException, bzcompress, file_exists,
file_put_contents, function_exists, gzcompress, str_repeat, strrpos, unlink,
};
@@ -147,7 +147,9 @@ impl ArchiverInterface for PharArchiver {
"Could not create archive '{}' from '{}': {}",
target_outer, sources, e
);
- RuntimeException::new(message).into()
+ let code = AnyThrowable::of(e.as_ref()).map_or(0, AnyThrowable::get_code);
+ RuntimeException::with_code_and_previous(message, code, Some(std::sync::Arc::new(e)))
+ .into()
})
}
diff --git a/crates/shirabe/src/package/loader/array_loader.rs b/crates/shirabe/src/package/loader/array_loader.rs
index 2c6d3971..106f094e 100644
--- a/crates/shirabe/src/package/loader/array_loader.rs
+++ b/crates/shirabe/src/package/loader/array_loader.rs
@@ -19,8 +19,9 @@ use chrono::Utc;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_php_shim::{
- E_USER_DEPRECATED, PhpMixed, UnexpectedValueException, is_scalar, is_string, json_encode,
- ltrim, php_regex, stripos, strpos, strtolower, strval, substr, trigger_error, trim,
+ AnyThrowable, E_USER_DEPRECATED, PhpMixed, UnexpectedValueException, is_scalar, is_string,
+ json_encode, ltrim, php_regex, stripos, strpos, strtolower, strval, substr, trigger_error,
+ trim,
};
#[derive(Debug)]
@@ -112,11 +113,17 @@ impl ArrayLoader {
{
Ok(v) => version = v,
Err(e) => {
- return Err(UnexpectedValueException::new(format!(
+ let message = format!(
"Failed to normalize version for package \"{}\": {}",
config.get("name").and_then(|v| v.as_string()).unwrap_or(""),
e
- ))
+ );
+ let code = AnyThrowable::of(e.as_ref()).map_or(0, AnyThrowable::get_code);
+ return Err(UnexpectedValueException::with_code_and_previous(
+ message,
+ code,
+ Some(std::sync::Arc::new(e)),
+ )
.into());
}
}
@@ -654,11 +661,17 @@ impl ArrayLoader {
let parsed_constraint = match self.version_parser.parse_constraints(&constraint) {
Ok(c) => c,
- Err(_e) => {
- return Err(UnexpectedValueException::new(format!(
+ Err(e) => {
+ let message = format!(
"Link constraint in {} {} > {} should be a valid version constraint, got \"{}\"",
source, description, target, constraint
- ))
+ );
+ let code = AnyThrowable::of(e.as_ref()).map_or(0, AnyThrowable::get_code);
+ return Err(UnexpectedValueException::with_code_and_previous(
+ message,
+ code,
+ Some(std::sync::Arc::new(e)),
+ )
.into());
}
};