From 7e31bab9ff7209c9b6d7928a581d7a449846f42e Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 2 Aug 2026 17:32:43 +0900 Subject: fix(json): propagate JsonFile::encode errors instead of unwrapping PHP's JsonFile::encode throws a RuntimeException when json_encode fails; the port swallowed that into an .unwrap() marked TODO(phase-c). Return anyhow::Result from encode/encode_with_options and propagate at every call site (print_table and list_repositories become Result-returning to carry it). Co-Authored-By: Claude Fable 5 --- crates/shirabe/tests/package/locker_test.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'crates/shirabe/tests/package/locker_test.rs') diff --git a/crates/shirabe/tests/package/locker_test.rs b/crates/shirabe/tests/package/locker_test.rs index c355c774..f1747166 100644 --- a/crates/shirabe/tests/package/locker_test.rs +++ b/crates/shirabe/tests/package/locker_test.rs @@ -17,7 +17,7 @@ fn null_io() -> std::rc::Rc> { std::rc::Rc::new(std::cell::RefCell::new(NullIO::new())) } -/// ref: LockerTest::getJsonContent — `JsonFile::encode(ksort([minimum-stability, name]), 0)`. +/// ref: LockerTest::getJsonContent — `JsonFile::encode(ksort([minimum-stability, name]), 0).unwrap()`. fn get_json_content(custom_data: &[(&str, &str)]) -> String { let mut data: IndexMap = IndexMap::new(); data.insert( @@ -30,7 +30,7 @@ fn get_json_content(custom_data: &[(&str, &str)]) -> String { } data.sort_keys(); - JsonFile::encode_with_options(&PhpMixed::Array(data), JsonEncodeOptions::none()) + JsonFile::encode_with_options(&PhpMixed::Array(data), JsonEncodeOptions::none()).unwrap() } /// Builds a `Locker` backed by a real `composer.lock` `JsonFile` inside a fresh temp dir, @@ -246,7 +246,8 @@ fn test_is_fresh_false() { m }), JsonEncodeOptions::none(), - ); + ) + .unwrap(); let (mut locker, _temp_dir, _io) = make_locker(&json_content, Some(&lock)); assert!(!locker.is_fresh().unwrap()); -- cgit v1.3.1