From a6fc2831562fa83b8f20a3b8285b87102c1775d8 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 9 Aug 2026 00:10:39 +0900 Subject: 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) --- crates/shirabe/src/json/json_file.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'crates/shirabe/src/json/json_file.rs') 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::() { 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::() { + return Err(e); + } return Err(RuntimeException::new(format!( "Could not read {}\n\n{}", self.path, e -- cgit v1.3.1-4-g156e