CustomExceptionHandler deve utlizar Throwable

production 0.1.1
parent 7ea7fc6746
commit 83203e8f9a

@ -3,7 +3,7 @@
namespace Ae3\LaravelLogsLayer\app\Exceptions; namespace Ae3\LaravelLogsLayer\app\Exceptions;
use Ae3\LaravelLogsLayer\app\Enums\LogsLevelsEnum; use Ae3\LaravelLogsLayer\app\Enums\LogsLevelsEnum;
use Exception; use Throwable;
use Ae3\LaravelLogsLayer\app\Traits\LogTrait; use Ae3\LaravelLogsLayer\app\Traits\LogTrait;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
@ -27,11 +27,11 @@ class CustomExceptionHandler extends ExceptionHandler
/** /**
* Report or log an exception. * Report or log an exception.
* *
* @param Exception $exception * @param Throwable $exception
* @return void * @return void
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function report(Exception $exception) public function report(Throwable $exception)
{ {
$level = $this->getExceptionLevel($exception); $level = $this->getExceptionLevel($exception);
$this->logException(__METHOD__, $exception, $level); $this->logException(__METHOD__, $exception, $level);
@ -41,19 +41,19 @@ class CustomExceptionHandler extends ExceptionHandler
* Render an exception into an HTTP response. * Render an exception into an HTTP response.
* *
* @param Request $request * @param Request $request
* @param Exception $exception * @param Throwable $exception
* @return JsonResponse|Response|\Symfony\Component\HttpFoundation\Response * @return JsonResponse|Response|\Symfony\Component\HttpFoundation\Response
*/ */
public function render($request, Exception $exception) public function render($request, Throwable $exception)
{ {
return parent::render($request, $exception); return parent::render($request, $exception);
} }
/** /**
* @param Exception $exception * @param Throwable $exception
* @return string * @return string
*/ */
protected function getExceptionLevel(Exception $exception): string protected function getExceptionLevel(Throwable $exception): string
{ {
if (method_exists($exception, 'getLevel')) { if (method_exists($exception, 'getLevel')) {
return mb_strtolower($exception->getLevel()); return mb_strtolower($exception->getLevel());

Loading…
Cancel
Save