Specify MDJsonEncodingFailedException for failure to encode JSON through

MD_STD::json_encode
This commit is contained in:
Joshua Ramon Enslin 2021-11-26 03:23:07 +01:00
parent 8f5174e90d
commit 86c8235dae
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE
2 changed files with 21 additions and 2 deletions

View File

@ -0,0 +1,19 @@
<?PHP
declare(strict_types = 1);
/**
* Reports a failure to encode JSON data.
*/
final class MDJsonEncodingFailedException extends Exception {
/**
* Error message.
*
* @return string
*/
public function errorMessage() {
//error message
$errorMsg = 'Failed to encode JSON data.';
return $errorMsg;
}
}

View File

@ -242,7 +242,7 @@ final class MD_STD {
$output = \json_encode($value, $options, $depth);
if ($output === false) {
throw new Exception("JSON output could not be generated");
throw new MDJsonEncodingFailedException("JSON output could not be generated");
}
return $output;
@ -263,7 +263,7 @@ final class MD_STD {
$output = \json_encode($value, $options, $depth);
if ($output === false) {
throw new Exception("JSON output could not be generated");
throw new MDJsonEncodingFailedException("JSON output could not be generated");
}
return $output;