Skip to content

Commit eecbdc3

Browse files
committed
a few fixes from Copilot review
1 parent 3d0599e commit eecbdc3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

flight/util/Json.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static function encode($data, int $options = 0, int $depth = 512): string
4141
try {
4242
return json_encode($data, $options, $depth);
4343
} catch (JsonException $e) {
44-
throw new JsonException('JSON encoding failed: ' . $e->getMessage(), $e->getCode(), $e);
44+
throw new Exception('JSON encoding failed: ' . $e->getMessage(), $e->getCode(), $e);
4545
}
4646
}
4747

@@ -56,13 +56,13 @@ public static function encode($data, int $options = 0, int $depth = 512): string
5656
* @return mixed Decoded data
5757
* @throws Exception If decoding fails
5858
*/
59-
public static function decode(string $json, bool $associative = false, int $depth = 512, int $options = self::DEFAULT_DECODE_OPTIONS)
59+
public static function decode(string $json, bool $associative = false, int $depth = 512, int $options = 0)
6060
{
6161
$options = $options | self::DEFAULT_DECODE_OPTIONS; // Ensure default options are applied
6262
try {
6363
return json_decode($json, $associative, $depth, $options);
6464
} catch (JsonException $e) {
65-
throw new JsonException('JSON decoding failed: ' . $e->getMessage(), $e->getCode(), $e);
65+
throw new Exception('JSON decoding failed: ' . $e->getMessage(), $e->getCode(), $e);
6666
}
6767
}
6868

tests/EngineTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public function testJsonWithDuplicateDefaultFlags()
398398
public function testJsonThrowOnErrorByDefault()
399399
{
400400
$engine = new Engine();
401-
$this->expectException(JsonException::class);
401+
$this->expectException(Exception::class);
402402
$this->expectExceptionMessage('Malformed UTF-8 characters, possibly incorrectly encoded');
403403
$engine->json(['key1' => 'value1', 'key2' => 'value2', 'utf8_emoji' => "\xB1\x31"]);
404404
}

0 commit comments

Comments
 (0)