1. Go to this page and download the library: Download phrity/util-errorhandler 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/ */
phrity / util-errorhandler example snippets
use Phrity\Util\ErrorHandler;
$handler = new ErrorHandler();
$result = $handler->with(function () {
// Code to execute
return $success_result;
});
$result = $handler->withAll(function () {
// Code to execute
return $success_result;
});
use Phrity\Util\ErrorHandler;
$handler = new ErrorHandler();
$result = $handler->with(function () {
// Code to execute
return $success_result;
}, new RuntimeException('A specified error'));
$result = $handler->withAll(function () {
// Code to execute
return $success_result;
}, new RuntimeException('A specified error'));
use Phrity\Util\ErrorHandler;
$handler = new ErrorHandler();
$result = $handler->with(function () {
// Code to execute
return $success_result;
}, function (ErrorException $error) {
// Code to handle error
return $error_result;
});
$result = $handler->withAll(function () {
// Code to execute
return $success_result;
}, function (array $errors, $success_result) {
// Code to handle errors
return $error_result;
});
use Phrity\Util\ErrorHandler;
$handler = new ErrorHandler();
$result = $handler->with(function () {
// Code to execute
return $success_result;
}, null, E_USER_ERROR);
$result = $handler->withAll(function () {
// Code to execute
return $success_result;
}, null, E_USER_ERROR & E_USER_WARNING);
use Phrity\Util\ErrorHandler;
$handler = new ErrorHandler();
$handler->set(); // Throws ErrorException on error
$handler->set(new RuntimeException('A specified error')); // Throws provided Throwable on error
$handler->set(function (ErrorException $error) {
// Code to handle errors
return $error_result;
}); // Runs callback on error
$handler->restore(); // Restores error handler
Phrity\Util\ErrorHandler {
/* Methods */
public __construct()
public with(callable $callback, mixed $handling = null, int $levels = E_ALL) : mixed
public withAll(callable $callback, mixed $handling = null, int $levels = E_ALL) : mixed
public set($handling = null, int $levels = E_ALL) : mixed
public restore() : bool
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.