Skip to content

Commit

Permalink
Fixed HttpException will not be handled in business exception handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
limingxinleo committed Jul 5, 2021
1 parent f5bcb40 commit e2025dd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/Exception/Handler/BusinessExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Di\Exception\CircularDependencyException;
use Hyperf\ExceptionHandler\ExceptionHandler;
use Hyperf\HttpMessage\Exception\HttpException;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseInterface;
use Throwable;
Expand Down Expand Up @@ -48,6 +49,8 @@ public function __construct(ContainerInterface $container)
public function handle(Throwable $throwable, ResponseInterface $response)
{
switch (true) {
case $throwable instanceof HttpException:
return $this->response->handleException($throwable);
case $throwable instanceof BusinessException:
$this->logger->warning(format_throwable($throwable));
return $this->response->fail($throwable->getCode(), $throwable->getMessage());
Expand Down

0 comments on commit e2025dd

Please sign in to comment.