feat: implement exception handling system with error context and policies
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\ExceptionHandling\Strategy;
|
||||
|
||||
use App\Framework\ExceptionHandling\ErrorContext;
|
||||
use App\Framework\ExceptionHandling\ErrorDecision;
|
||||
use App\Framework\ExceptionHandling\ErrorHandlerStrategy;
|
||||
use ErrorException;
|
||||
|
||||
final readonly class StrictErrorPolicy implements ErrorHandlerStrategy
|
||||
{
|
||||
/**
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function handle(ErrorContext $context): ErrorDecision
|
||||
{
|
||||
throw new ErrorException($context->message, 0, $context->severity, $context->file, $context->line);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user