Skip to content

Commit

Permalink
fix issue when renderable receives a query exception
Browse files Browse the repository at this point in the history
  • Loading branch information
d8vjork committed Jan 25, 2023
1 parent 34e0446 commit e312ba5
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Support/Apiable.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\QueryException;
use Illuminate\Http\Resources\MissingValue;
use Illuminate\Http\Response;
use Illuminate\Support\Arr;
Expand Down Expand Up @@ -113,7 +114,7 @@ public static function jsonApiRenderable(Throwable $e, $request)
}

if ($statusCode === Response::HTTP_INTERNAL_SERVER_ERROR) {
$response['errors'][0]['code'] = $e->getCode() ?: $statusCode;
$response['errors'][0]['code'] = $e instanceof QueryException ? $statusCode : ($e->getCode() ?: $statusCode);
$response['errors'][0]['title'] = $e->getMessage();
$response['errors'][0]['trace'] = $e->getTrace();
}
Expand Down

0 comments on commit e312ba5

Please sign in to comment.