1. Go to this page and download the library: Download krmgns/errorise library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
krmgns / errorise example snippets
use Errorise;
$eh = new Errorise\ErrorHandler();
try {
fopen('/path/to/file.txt', 'r');
// Throws if any error occured.
$eh->throw();
} catch (Errorise\ErrorException $e) {
// Message: fopen(/path/to/file.txt): Failed to open ...
throw new YourCustomException_After_Some_Business(
$e->getMessage()
);
} finally {
// Trigger handler __destruct() to call unregister().
unset($eh);
}
try {
fopen('/path/to/file.txt', 'r');
// Throws if any error occured with fopen().
$eh->throwFor('fopen');
// Throws if any error occured with message pattern.
$eh->throwForMatch('/fopen/');
} catch (Errorise\ErrorException $e) {
// ...
} finally {
// ...
}