Skip to content

dmitry-suffi/error-handler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ErrorHandler

Error handling php. Can use any logger psr-3 for logging errors.

Installation

composer require dmitry-suffi/error-handler

connection example

$handler = new \suffi\ErrorHandler\ErrorHandler();

set_error_handler([$handler, 'errorHandler']);
set_exception_handler([$handler, 'exceptionHandler']);

Setting

Debug mode. Displays error details.

$handler->debug = true;

Error Logging. Can use any logger psr-3 for logging errors.

$handler->writeLog = true;

$handler->logger = $logger;

Writing to the log information

$handler->$debugLog = true;

When you inherit from the class, you can change the way display messages to the user fault conditioning.

    //Page with an error message
    protected function htmlError(string $errstr)
    {
        return $errstr;
    }

    //Report an error for ajax-request
    protected function jsonError(string $errstr)
    {
        return json_encode(['error' => $errstr]);
    }