Fix error rendering while ServerException

This commit is contained in:
Djery-Tom 2023-06-09 13:54:27 +01:00
parent 5fbe780ef5
commit 161f8b5bf9
4 changed files with 1582 additions and 1422 deletions

View File

@ -109,7 +109,11 @@ class Handler extends ExceptionHandler
if ($exception instanceof ServerException) if ($exception instanceof ServerException)
{ {
return $this->errorResponse($exception->getMessage(),Response::HTTP_INTERNAL_SERVER_ERROR); $errorBody = $exception->getResponse()->getBody()->getContents();
$error = json_decode($errorBody);
$message = $error ? $error->error : $exception->getMessage();
$code = $error ? $error->status : Response::HTTP_INTERNAL_SERVER_ERROR;
return $this->errorResponse($message,$code);
} }
if( env('APP_DEBUG', false)) if( env('APP_DEBUG', false))

View File

@ -115,6 +115,7 @@ $app->register(App\Providers\AuthServiceProvider::class);
//$app->register(SMartins\PassportMultiauth\Providers\MultiauthServiceProvider::class); //$app->register(SMartins\PassportMultiauth\Providers\MultiauthServiceProvider::class);
$app->register(Laravel\Passport\PassportServiceProvider::class); $app->register(Laravel\Passport\PassportServiceProvider::class);
$app->register(Dusterio\LumenPassport\PassportServiceProvider::class); $app->register(Dusterio\LumenPassport\PassportServiceProvider::class);
$app->register(Flipbox\LumenGenerator\LumenGeneratorServiceProvider::class);
/* /*

View File

@ -5,11 +5,12 @@
"license": "MIT", "license": "MIT",
"type": "project", "type": "project",
"require": { "require": {
"php": "^7.3|^8.0", "php": "^8.0",
"ext-json": "*",
"dusterio/lumen-passport": "^0.3.0", "dusterio/lumen-passport": "^0.3.0",
"flipbox/lumen-generator": "^9.2",
"guzzlehttp/guzzle": "^7.3", "guzzlehttp/guzzle": "^7.3",
"laravel/lumen-framework": "^8.0", "laravel/lumen-framework": "^8.0"
"ext-json": "*"
}, },
"require-dev": { "require-dev": {
"fzaninotto/faker": "^1.9.1", "fzaninotto/faker": "^1.9.1",

2990
composer.lock generated

File diff suppressed because it is too large Load Diff