Specify MDJsonEncodingFailedException for failure to encode JSON through
MD_STD::json_encode
This commit is contained in:
parent
8f5174e90d
commit
86c8235dae
19
exceptions/MDJsonEncodingFailedException.php
Normal file
19
exceptions/MDJsonEncodingFailedException.php
Normal 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;
|
||||
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user