Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| JsonException | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php declare(strict_types=1); |
| 2 | /** |
| 3 | * PrivateBin |
| 4 | * |
| 5 | * a zero-knowledge paste bin |
| 6 | * |
| 7 | * @link https://github.com/PrivateBin/PrivateBin |
| 8 | * @copyright 2012 Sébastien SAUVAGE (sebsauvage.net) |
| 9 | * @license https://www.opensource.org/licenses/zlib-license.php The zlib/libpng License |
| 10 | */ |
| 11 | |
| 12 | namespace PrivateBin\Exception; |
| 13 | |
| 14 | use Exception; |
| 15 | |
| 16 | /** |
| 17 | * JsonException |
| 18 | * |
| 19 | * An Exception representing JSON en- or decoding errors. |
| 20 | */ |
| 21 | class JsonException extends Exception |
| 22 | { |
| 23 | /** |
| 24 | * Exception constructor with mandatory JSON error code. |
| 25 | * |
| 26 | * @access public |
| 27 | * @param int $code |
| 28 | */ |
| 29 | public function __construct(int $code) |
| 30 | { |
| 31 | $message = 'A JSON error occurred'; |
| 32 | if (function_exists('json_last_error_msg')) { |
| 33 | $message .= ': ' . json_last_error_msg(); |
| 34 | } |
| 35 | $message .= ' (' . $code . ')'; |
| 36 | parent::__construct($message, 90); |
| 37 | } |
| 38 | } |