feat: implement exception handling system with error context and policies
This commit is contained in:
25
src/Framework/ExceptionHandling/ErrorKernel.php
Normal file
25
src/Framework/ExceptionHandling/ErrorKernel.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\ExceptionHandling;
|
||||
|
||||
use App\Framework\ExceptionHandling\Reporter\LogReporter;
|
||||
use Throwable;
|
||||
|
||||
final readonly class ErrorKernel
|
||||
{
|
||||
public function __construct(
|
||||
private ErrorRendererFactory $rendererFactory = new ErrorRendererFactory,
|
||||
) {}
|
||||
public function handle(Throwable $e, array $context = []): mixed
|
||||
{
|
||||
|
||||
$log = new LogReporter();
|
||||
$log->report($e->getMessage());
|
||||
|
||||
$this->rendererFactory->getRenderer()->render();
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user