aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/json
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-09 00:10:39 +0900
committernsfisis <nsfisis@gmail.com>2026-08-09 00:14:34 +0900
commita6fc2831562fa83b8f20a3b8285b87102c1775d8 (patch)
tree715af4c233cdfc7355a42aeab17316d76051562e /crates/shirabe/src/json
parent5ffe30e9962524415cd12b31e094bf75ca4e4908 (diff)
downloadphp-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/shirabe/src/json')
-rw-r--r--crates/shirabe/src/json/json_file.rs6
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