diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-10 00:54:22 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-10 00:54:58 +0900 |
| commit | e583112899cbea7494ffdd73d7de380dd5f808c4 (patch) | |
| tree | 1ec002a4d9ab5af5f81ff3bc0ae0ea6a92e44c10 /crates/shirabe/src/json | |
| parent | 436e12381dd79e419dce755718be17b66d73e17f (diff) | |
| download | php-shirabe-e583112899cbea7494ffdd73d7de380dd5f808c4.tar.gz php-shirabe-e583112899cbea7494ffdd73d7de380dd5f808c4.tar.zst php-shirabe-e583112899cbea7494ffdd73d7de380dd5f808c4.zip | |
feat(phase-c): resolve exception-handling phase-b TODOs
* Catch specific exception types instead of broad/placeholder handling.
* Drop the shim Countable trait.
Diffstat (limited to 'crates/shirabe/src/json')
| -rw-r--r-- | crates/shirabe/src/json/json_file.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs index a185084..cf92a77 100644 --- a/crates/shirabe/src/json/json_file.rs +++ b/crates/shirabe/src/json/json_file.rs @@ -404,9 +404,9 @@ impl JsonFile { validator.check(&data_converted, &schema_data)?; if !validator.is_valid() { - // TODO(phase-b): Validator::get_errors currently returns Vec<String>; original PHP - // exposes [{property, message}, ...]. Until shim is enriched, surface raw error - // strings without prop/message splitting. + // TODO(phase-c): Validator::get_errors currently returns Vec<String>; original PHP + // exposes [{property, message}, ...]. Until the validator shim is enriched, surface raw + // error strings without prop/message splitting. let errors: Vec<String> = validator.get_errors(); return Err(JsonValidationException::new( format!("\"{}\" does not match the expected JSON schema", source), @@ -431,8 +431,9 @@ impl JsonFile { let json = match json { Some(j) => j, None => { - // PHP: self::throwEncodeError(json_last_error()); - // TODO(phase-b): throw an error; downstream callers expect a String + // PHP: self::throwEncodeError(json_last_error()), which throws \RuntimeException. + // TODO(phase-c): faithfully propagating this requires encode/encode_with_options to + // return Result<String>, a signature change rippling across ~53 call sites. Self::throw_encode_error(json_last_error()).unwrap_or_default(); String::new() } |
