Initial commit, framework/frontend assets setup
This commit is contained in:
commit
9d9858bb37
32 changed files with 4651 additions and 0 deletions
55
src/Exceptions/Exceptions.php
Normal file
55
src/Exceptions/Exceptions.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Core\Exceptions;
|
||||
|
||||
use Throwable;
|
||||
use Whoops\Handler\PrettyPageHandler;
|
||||
use Whoops\Run as Whoops;
|
||||
|
||||
class Exceptions
|
||||
{
|
||||
/**
|
||||
* Exceptions handler instance
|
||||
*
|
||||
* @var Whoops
|
||||
*/
|
||||
private static Whoops $instance;
|
||||
|
||||
/**
|
||||
* Get exceptions handler instance
|
||||
*
|
||||
* @return \Whoops\Run
|
||||
*/
|
||||
public static function handler(): Whoops
|
||||
{
|
||||
if (!isset(self::$instance)) {
|
||||
$instance = new Whoops();
|
||||
$instance->pushHandler(new PrettyPageHandler());
|
||||
|
||||
self::$instance = $instance;
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch all exceptions
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function catch(): void
|
||||
{
|
||||
self::handler()->register();
|
||||
}
|
||||
|
||||
/**
|
||||
* Catch single exception
|
||||
*
|
||||
* @param \Throwable $exception
|
||||
* @return void
|
||||
*/
|
||||
public static function catchOne(Throwable $exception): void
|
||||
{
|
||||
self::handler()->handleException($exception);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue