mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 19:27:48 +08:00
35 lines
929 B
PHP
35 lines
929 B
PHP
<?php
|
|
|
|
namespace App\Exception\Handler;
|
|
|
|
use App\Exception\ErrException;
|
|
use Psr\Container\ContainerExceptionInterface;
|
|
use Psr\Container\NotFoundExceptionInterface;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Throwable;
|
|
|
|
class ErrExceptionHandler extends BaseErrExceptionHandler
|
|
{
|
|
/**
|
|
* @param Throwable $throwable
|
|
* @param ResponseInterface $response
|
|
* @return ResponseInterface
|
|
* @throws ContainerExceptionInterface
|
|
* @throws NotFoundExceptionInterface
|
|
*/
|
|
public function handle(Throwable $throwable, ResponseInterface $response): ResponseInterface
|
|
{
|
|
return $throwable instanceof ErrException
|
|
? $this->handlerResponse($throwable, $response)
|
|
: $response;
|
|
}
|
|
|
|
/**
|
|
* @param Throwable $throwable
|
|
* @return bool
|
|
*/
|
|
public function isValid(Throwable $throwable): bool
|
|
{
|
|
return $throwable instanceof ErrException;
|
|
}
|
|
} |