diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-05 01:52:51 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-05 01:52:51 +0900 |
| commit | b62d937331860b5cf17737c9f6be8a015bda102c (patch) | |
| tree | 1f188c21d1e52d923733d61c47626e340929adc8 /crates/shirabe | |
| parent | bbb2f9454b6580fcbd337ced61b5a1888d52ce8d (diff) | |
| download | php-shirabe-b62d937331860b5cf17737c9f6be8a015bda102c.tar.gz php-shirabe-b62d937331860b5cf17737c9f6be8a015bda102c.tar.zst php-shirabe-b62d937331860b5cf17737c9f6be8a015bda102c.zip | |
refactor(downloader): return Result from GitDownloader::view_diff
PHP's viewDiff returns void but throws RuntimeException when git diff
fails. Model it as Result<()> and propagate via ? at the single caller
instead of panicking.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe')
| -rw-r--r-- | crates/shirabe/src/downloader/git_downloader.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/crates/shirabe/src/downloader/git_downloader.rs b/crates/shirabe/src/downloader/git_downloader.rs index 26ff4aa..bc8db6d 100644 --- a/crates/shirabe/src/downloader/git_downloader.rs +++ b/crates/shirabe/src/downloader/git_downloader.rs @@ -618,7 +618,7 @@ impl GitDownloader { } /// @throws \RuntimeException - pub(crate) fn view_diff(&mut self, path: &str) { + pub(crate) fn view_diff(&mut self, path: &str) -> Result<()> { let path = self.normalize_path(path); let mut output = String::new(); if self.inner.process.borrow_mut().execute_args( @@ -627,13 +627,18 @@ impl GitDownloader { Some(path.clone()), ) != 0 { - // TODO(phase-b): cannot throw from non-Result fn; bubble error via Result later - panic!("{}", format!("Could not view diff\n\n:{}", output)); + return Err(RuntimeException { + message: format!("Could not view diff\n\n:{}", output), + code: 0, + } + .into()); } self.inner .io .write_error3(&output, true, io_interface::NORMAL); + + Ok(()) } pub(crate) fn normalize_path(&self, path: &str) -> String { @@ -1283,7 +1288,7 @@ impl VcsDownloader for GitDownloader { .write_error3(&changes.join("\n"), true, io_interface::NORMAL); } Some("d") => { - self.view_diff(&path); + self.view_diff(&path)?; } _ => { // case '?': default: |
