diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-03 00:57:47 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-03 01:13:55 +0900 |
| commit | 8888e4b8bfeb41e4edd45ab47db8a293e93ded3f (patch) | |
| tree | eb37ebb6dc44b33d1bcf843ce0228e24cd58d221 /crates/shirabe/src/repository | |
| parent | 37f10618689c55d651028487c39988fedcb593ea (diff) | |
| download | php-shirabe-8888e4b8bfeb41e4edd45ab47db8a293e93ded3f.tar.gz php-shirabe-8888e4b8bfeb41e4edd45ab47db8a293e93ded3f.tar.zst php-shirabe-8888e4b8bfeb41e4edd45ab47db8a293e93ded3f.zip | |
feat(downloader,repository): wire exception instanceof downcasts via anyhow
Resolve the PHP try/catch instanceof checks that select on exception type:
TransportException-only catches in RepositorySet, SvnDriver and JsonFile;
the RuntimeException/IrrecoverableDownloadException handleError closure and
the RuntimeException update-retry catch in DownloadManager. Each uses
anyhow::Error::downcast_ref and reads the exception's message field directly
(Display is todo\!() on the shim exceptions). PHPUnit\Framework\Exception
checks in VcsDownloader are documented as intentionally always-false since
the test framework is out of scope.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/repository')
| -rw-r--r-- | crates/shirabe/src/repository/repository_set.rs | 14 | ||||
| -rw-r--r-- | crates/shirabe/src/repository/vcs/svn_driver.rs | 12 |
2 files changed, 20 insertions, 6 deletions
diff --git a/crates/shirabe/src/repository/repository_set.rs b/crates/shirabe/src/repository/repository_set.rs index ac904fc..1323fbd 100644 --- a/crates/shirabe/src/repository/repository_set.rs +++ b/crates/shirabe/src/repository/repository_set.rs @@ -395,12 +395,20 @@ impl RepositorySet { match attempt { Ok(_) => {} Err(e) => { - // TODO(phase-b): downcast e to \Composer\Downloader\TransportException - let _te: &TransportException = todo!("downcast e to TransportException"); + // PHP catches only \Composer\Downloader\TransportException; other + // exceptions propagate uncaught. + if e.downcast_ref::<TransportException>().is_none() { + return Err(e); + } if !ignore_unreachable { return Err(e); } - unreachable_repos.push(e.to_string()); + let message = e + .downcast_ref::<TransportException>() + .unwrap() + .message + .clone(); + unreachable_repos.push(message); } } } diff --git a/crates/shirabe/src/repository/vcs/svn_driver.rs b/crates/shirabe/src/repository/vcs/svn_driver.rs index a793340..2812c8d 100644 --- a/crates/shirabe/src/repository/vcs/svn_driver.rs +++ b/crates/shirabe/src/repository/vcs/svn_driver.rs @@ -184,9 +184,15 @@ impl SvnDriver { let composer: Option<IndexMap<String, PhpMixed>> = match base_result { Ok(c) => c, Err(e) => { - // TODO(phase-b): downcast to TransportException - let _te: &TransportException = todo!("downcast e to TransportException"); - let message = e.to_string(); + // PHP catches only TransportException; other exceptions propagate uncaught. + if e.downcast_ref::<TransportException>().is_none() { + return Err(e); + } + let message = e + .downcast_ref::<TransportException>() + .unwrap() + .message + .clone(); if stripos(&message, "path not found").is_none() && stripos(&message, "svn: warning: W160013").is_none() { |
