diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-09 00:10:39 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-09 00:14:34 +0900 |
| commit | a6fc2831562fa83b8f20a3b8285b87102c1775d8 (patch) | |
| tree | 715af4c233cdfc7355a42aeab17316d76051562e /crates | |
| parent | 5ffe30e9962524415cd12b31e094bf75ca4e4908 (diff) | |
| download | php-shirabe-a6fc2831562fa83b8f20a3b8285b87102c1775d8.tar.gz php-shirabe-a6fc2831562fa83b8f20a3b8285b87102c1775d8.tar.zst php-shirabe-a6fc2831562fa83b8f20a3b8285b87102c1775d8.zip | |
fix(json): let an \Error out of JsonFile::read untouched
The port's fall-through stood in for PHP's `catch (\Exception $e)`, which
does not catch an `\Error`; a TypeError reaching JsonFile::read would come
back out as a `\RuntimeException` saying the file could not be read.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/shirabe/src/json/json_file.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs index da6370e4..feb72764 100644 --- a/crates/shirabe/src/json/json_file.rs +++ b/crates/shirabe/src/json/json_file.rs @@ -171,8 +171,6 @@ impl JsonFile { })() { Ok(j) => j, Err(e) => { - // TransportException keeps its message verbatim; any other exception is wrapped - // with the "Could not read" prefix. if let Some(te) = e.catch::<TransportException>() { let message = te.get_message().to_string(); return Err(RuntimeException::with_code_and_previous( @@ -182,6 +180,10 @@ impl JsonFile { ) .into()); } + // `catch (\Exception)` leaves an \Error to propagate. + if e.is_instanceof::<shirabe_php_shim::Error>() { + return Err(e); + } return Err(RuntimeException::new(format!( "Could not read {}\n\n{}", self.path, e |
