https://github.com/dmitry-suffi/error-handler
ErrorHandler
https://github.com/dmitry-suffi/error-handler
errorhandler
Last synced: 9 days ago
JSON representation
ErrorHandler
- Host: GitHub
- URL: https://github.com/dmitry-suffi/error-handler
- Owner: dmitry-suffi
- License: mit
- Created: 2017-01-10T14:22:48.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-08-06T18:10:26.000Z (over 7 years ago)
- Last Synced: 2025-05-08T20:14:41.228Z (9 months ago)
- Topics: errorhandler
- Language: PHP
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
ErrorHandler
============
Error handling php. Can use any logger psr-3 for logging errors.
Installation
------------
```
composer require dmitry-suffi/error-handler
```
connection example
------------------
```php
$handler = new \suffi\ErrorHandler\ErrorHandler();
set_error_handler([$handler, 'errorHandler']);
set_exception_handler([$handler, 'exceptionHandler']);
```
Setting
-------
Debug mode. Displays error details.
```php
$handler->debug = true;
```
Error Logging. Can use any logger psr-3 for logging errors.
```php
$handler->writeLog = true;
$handler->logger = $logger;
```
Writing to the log information
```php
$handler->$debugLog = true;
```
When you inherit from the class, you can change the way display messages to the user fault conditioning.
```php
//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]);
}
```