/
adssoft
/
ads_goskey_api
Обзор
Документация
Войти
/
adssoft
/
ads_goskey_api
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
app/Exceptions/Handler.php
106 строк
3 KB
Viatcheslav Malakhov
update
23 мар 2026, 17:28
23 мар 2026, 17:28
09e4e2a
Код
Авторство
О чём код?
<?php namespace App\Exceptions; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; class Handler extends ExceptionHandler { /** * A list of exception types with their corresponding custom log levels. * * @var array<class-string<\Throwable>, \Psr\Log\LogLevel::*> */ protected $levels = [ // ]; /** * A list of the exception types that are not reported. * * @var array<int, class-string<\Throwable>> */ protected $dontReport = [ // ]; /** * A list of the inputs that are never flashed to the session on validation exceptions. * * @var array<int, string> */ protected $dontFlash = [ 'current_password', 'password', 'password_confirmation', ]; /** * Register the exception handling callbacks for the application. * * @return void */ public function register() { $this->reportable(function (Throwable $e) { // }); } public function render($request, Throwable $exception) { $code = 500; $trace = []; $message = ''; if ($request->wantsJson()) { if ($exception instanceof \Illuminate\Validation\ValidationException) { $code = 400; $message = $exception->validator->errors()->first(); } elseif ($exception instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) { $code = 404; $message = 'Requested method not found'; } elseif ($exception instanceof \Illuminate\Database\Eloquent\ModelNotFoundException) { $code = 404; $message = 'Requested entity not found'; } elseif ($exception instanceof \App\Exceptions\ApiException) { $code = 404; $message = $exception->getMessage(); } else { $message = $exception->getMessage(); if(stripos($message, '8007065B') !== false) { $message .= ' CryptoPro license is expired.'; } $trace = [ 'class' => get_class($exception), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'request' => request()->all(), 'stack' => $exception->getTrace(), ]; if(!config('app.debug')) { unset($trace['class'], $trace['file'], $trace['line'], $trace['stack']); } } return response()->error($message, $code, $trace); } return parent::render($request, $exception); } }