- $error = json_last_error();
- throw new Exception('An error occurred while parsing JSON file: error code #'. $error);
+ $errorCode = json_last_error();
+ $error = sprintf(
+ 'An error occurred while parsing JSON configuration file (%s): error code #%d',
+ $filepath,
+ $errorCode
+ );
+ $error .= '<br>➜ <code>' . json_last_error_msg() .'</code>';
+ if ($errorCode === JSON_ERROR_SYNTAX) {
+ $error .= '<br>';
+ $error .= 'Please check your JSON syntax (without PHP comment tags) using a JSON lint tool such as ';
+ $error .= '<a href="http://jsonlint.com/">jsonlint.com</a>.';
+ }
+ throw new \Exception($error);