SkillAgentSearch skills...

ErrorHandler

PHP class for causing all errors and exceptions to output as JSON formatted objects

Install / Use

/learn @PrimalPHP/ErrorHandler
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

ErrorHandler

Simple to use class for catching all uncaught errors for processing. By default the class outputs the error as JSON, but that behavior can be overridden with a custom callback. Designed to help with error reporting when building APIs, but useful in generic application settings as well. Handles Exceptions, Runtime Errors and Fatal Errors

##Usage

//defaults to outputting errors as application/json
\Primal\ErrorHandler::Init();

//override with a custom callback to write to a log file
\Primal\ErrorHandler::Init(function ($error) {
    error_log(json_encode($error), 0, '/path/to/error/log');
});
View on GitHub
GitHub Stars6
CategoryDevelopment
Updated3y ago
Forks1

Languages

PHP

Security Score

55/100

Audited on Aug 28, 2022

No findings