diff options
Diffstat (limited to 'crates/shirabe')
| -rw-r--r-- | crates/shirabe/src/config/json_config_source.rs | 8 | ||||
| -rw-r--r-- | crates/shirabe/src/package/loader/array_loader.rs | 5 |
2 files changed, 5 insertions, 8 deletions
diff --git a/crates/shirabe/src/config/json_config_source.rs b/crates/shirabe/src/config/json_config_source.rs index 7b5fc03..28481db 100644 --- a/crates/shirabe/src/config/json_config_source.rs +++ b/crates/shirabe/src/config/json_config_source.rs @@ -207,19 +207,19 @@ impl JsonConfigSource { )?; } - // TODO(phase-b): use anyhow::Result<Result<T, E>> to model PHP try/catch match self.file.validate_schema(JsonFile::LAX_SCHEMA, None) { Ok(_) => {} Err(e) => { - // TODO(phase-b): downcast e to JsonValidationException to match the specific catch - let _jve: &JsonValidationException = todo!("downcast e to JsonValidationException"); + let Some(jve) = e.downcast_ref::<JsonValidationException>() else { + return Err(e); + }; // restore contents to the original state file_put_contents(self.file.get_path(), contents.as_bytes()); return Err(RuntimeException { message: format!( "Failed to update composer.json with a valid format, reverting to the original content. Please report an issue to us with details (command you run and a copy of your composer.json). {}{}", PHP_EOL, - implode(PHP_EOL, todo!("e.get_errors()")), + implode(PHP_EOL, jve.get_errors()), ), code: 0, } diff --git a/crates/shirabe/src/package/loader/array_loader.rs b/crates/shirabe/src/package/loader/array_loader.rs index e1cc60b..634bef8 100644 --- a/crates/shirabe/src/package/loader/array_loader.rs +++ b/crates/shirabe/src/package/loader/array_loader.rs @@ -195,7 +195,6 @@ impl ArrayLoader { { Ok(v) => version = v, Err(e) => { - // TODO(phase-b): preserve original exception chain via anyhow::Error::context return Err(UnexpectedValueException { message: format!( "Failed to normalize version for package \"{}\": {}", @@ -761,9 +760,7 @@ impl ArrayLoader { let parsed_constraint = match self.version_parser.parse_constraints(&constraint) { Ok(c) => c, - Err(e) => { - // TODO(phase-b): preserve original exception chain - let _ = &e; + Err(_e) => { return Err(UnexpectedValueException { message: format!( "Link constraint in {} {} > {} should be a valid version constraint, got \"{}\"", |
