static function fromException($exception) { $exceptionClass = get_class($exception); $response = new self(); if ($exception instanceof \RpcException) { $response->setHttpStatus($exception->getHttpStatus()); $response->setCode($exception->getRpcErrorCode()); $response->setData(['data' => $exception->getData(), 'trace' => $exception->getTrace()]); } else { $response->setHttpStatus(500); $response->setCode('UNKOWN'); $response->setData(['trace' => $exception->getTrace()]); } $response->setMessage($exception->getMessage()); return $response; }
/** * @param $exception * @return Response */ static function fromException($exception) { $exceptionClass = get_class($exception); $response = new self(); if ($exception instanceof \RpcException) { $response->setHttpStatus($exception->getHttpStatus()); $response->setCode($exception->getRpcErrorCode()); $response->setData(['data' => $exception->getData(), 'trace' => $exception->getTrace()]); } else { $response->setHttpStatus(500); $response->setCode(ErrorMessages::JSONRPC_ERROR_UNKOWN_EXCEPTION_CODE); $response->setData(['trace' => $exception->getTrace()]); } $response->setMessage($exception->getMessage()); $response->error = ['code' => $response->code, 'message' => $response->message, 'data' => $response->data]; return $response; }