From c74f4314853c0e7283691fdd4d0dec27c1199537 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 8 Aug 2026 22:37:08 +0900 Subject: fix(exception): carry PHP's $previous through the ported throw sites Composer hands the exception it caught to the one it throws in its place, so `getPrevious()` reaches the cause and Application's renderer prints the whole chain. Every ported site dropped it, because the flat exception structs had nowhere to put one. `AnyThrowable::into_previous` turns the caught error into that argument, and the 13 sites now pass it. `getCode()` came along for the ride at the four sites that derive the new exception's code from the caught one (PharArchiver, ArrayLoader x2), and ComposerRepository's message now names the caught exception's class instead of the literal "Exception". GitHubDriver::attemptCloneFallback took the previous exception's message and appended it to its own, which no `\RuntimeException('Fallback to git driver disabled')` in Composer ever says; it now chains it instead. Git::syncMirror restores what PHP's `finally` does to an exception in flight: the `git remote set-url` that scrubs credentials back out of the URL runs in a `finally`, and when it fails PHP propagates *its* exception over the one already leaving, chaining the displaced one as previous. The port discarded the finally's result, so a failure to scrub the URL was reported as a successful mirror sync. `AnyThrowable::set_previous` models the engine-level chaining. Co-Authored-By: Claude Opus 5 (1M context) --- crates/shirabe/src/command/global_command.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'crates/shirabe/src/command/global_command.rs') diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs index 78b6f3e6..df9798a3 100644 --- a/crates/shirabe/src/command/global_command.rs +++ b/crates/shirabe/src/command/global_command.rs @@ -90,8 +90,12 @@ impl GlobalCommand { } } - chdir(&home).map_err(|_e| { - RuntimeException::new(format!("Could not switch to home directory \"{}\"", home)) + chdir(&home).map_err(|e| { + RuntimeException::with_code_and_previous( + format!("Could not switch to home directory \"{}\"", home), + 0, + Some(std::sync::Arc::new(e)), + ) })?; if !quiet { -- cgit v1.3.1-4-g156e