protected function parseException() { /** @var APIResponse $response */ $response = app(APIResponse::class); $fe = FlattenException::create($e); $data = env("APP_DEBUG", false) ? $fe->toArray() : ["message" => "whoops, something wrong."]; return JsonResponse::create($data, 500); }
/** * Helper method to return a JSON response. * * @param mixed $data * The data to return as the response. * @param int $status * The HTTP status code for this response. * * @return JsonResponse * */ public function toJson($data, $status = 200) { return JsonResponse::create($data, $status); }