Skip to content

codekandis/json-error-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codekandis/json-error-handler

Version License Minimum PHP Version Code Coverage

With the JSON error handler you will be able to catch exceptions representing the last occurred JSON error containing the native error codes and error messages of PHP's JSON package.

Index

Installation

Install the latest version with

$ composer require codekandis/json-error-handler

How to use

The following example throws a JsonException with the error code of JsonErrorCodes::SYNTAX with the message of JsonErrorMessage::SYNTAX.

json_decode( '{"foobar":}' );
( new JsonErrorHandler() )->handle();

The error codes in JsonErrorCodes are equal to PHP's native JSON_ERROR constants. The error messages in JsonErrorMessages are equal to PHP's error messages of json_last_error_msg().

About

`codekandis/json-error-handler` is a library to handle JSON errors in an object oriented way.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published