mirror of https://gitee.com/bigwinds/arangodb
Response can always be a nullptr
This commit is contained in:
parent
2275fc8174
commit
73b7d67510
|
@ -1167,44 +1167,43 @@ static bool throwExceptionAfterBadSyncRequest(ClusterCommResult* res,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res->status == CL_COMM_ERROR) {
|
if (res->status == CL_COMM_ERROR) {
|
||||||
std::string errorMessage;
|
std::string errorMessage = std::string("Error message received from shard '") +
|
||||||
TRI_ASSERT(nullptr != res->result);
|
|
||||||
|
|
||||||
arangodb::basics::StringBuffer const& responseBodyBuf(res->result->getBody());
|
|
||||||
|
|
||||||
// extract error number and message from response
|
|
||||||
int errorNum = TRI_ERROR_NO_ERROR;
|
|
||||||
std::shared_ptr<VPackBuilder> builder = VPackParser::fromJson(
|
|
||||||
responseBodyBuf.c_str(), responseBodyBuf.length());
|
|
||||||
VPackSlice slice = builder->slice();
|
|
||||||
|
|
||||||
if (!slice.hasKey("error") || slice.get("error").getBoolean()) {
|
|
||||||
errorNum = TRI_ERROR_INTERNAL;
|
|
||||||
errorMessage = std::string("Error message received from shard '") +
|
|
||||||
std::string(res->shardID) +
|
std::string(res->shardID) +
|
||||||
std::string("' on cluster node '") +
|
std::string("' on cluster node '") +
|
||||||
std::string(res->serverID) + std::string("': ");
|
std::string(res->serverID) + std::string("': ");
|
||||||
}
|
|
||||||
|
|
||||||
if (slice.isObject()) {
|
|
||||||
VPackSlice v = slice.get("errorNum");
|
|
||||||
|
|
||||||
if (v.isNumber()) {
|
int errorNum = TRI_ERROR_INTERNAL;
|
||||||
if (v.getNumericValue<int>() != TRI_ERROR_NO_ERROR) {
|
std::string errorDetailMessage = std::string("(no valid response)");
|
||||||
/* if we've got an error num, error has to be true. */
|
if (res->result != nullptr) {
|
||||||
TRI_ASSERT(errorNum == TRI_ERROR_INTERNAL);
|
errorNum = TRI_ERROR_NO_ERROR;
|
||||||
errorNum = v.getNumericValue<int>();
|
} else {
|
||||||
|
arangodb::basics::StringBuffer const& responseBodyBuf(res->result->getBody());
|
||||||
|
std::shared_ptr<VPackBuilder> builder = VPackParser::fromJson(
|
||||||
|
responseBodyBuf.c_str(), responseBodyBuf.length());
|
||||||
|
VPackSlice slice = builder->slice();
|
||||||
|
|
||||||
|
if (!slice.hasKey("error") || slice.get("error").getBoolean()) {
|
||||||
|
errorNum = TRI_ERROR_INTERNAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slice.isObject()) {
|
||||||
|
VPackSlice v = slice.get("errorNum");
|
||||||
|
if (v.isNumber()) {
|
||||||
|
if (v.getNumericValue<int>() != TRI_ERROR_NO_ERROR) {
|
||||||
|
/* if we've got an error num, error has to be true. */
|
||||||
|
TRI_ASSERT(errorNum == TRI_ERROR_INTERNAL);
|
||||||
|
errorNum = v.getNumericValue<int>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
v = slice.get("errorMessage");
|
||||||
|
if (v.isString()) {
|
||||||
|
errorMessage += v.copyString();
|
||||||
|
} else {
|
||||||
|
errorMessage += std::string("(no valid error in response)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
v = slice.get("errorMessage");
|
|
||||||
if (v.isString()) {
|
|
||||||
errorMessage += v.copyString();
|
|
||||||
} else {
|
|
||||||
errorMessage += std::string("(no valid error in response)");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
errorMessage += std::string("(no valid response)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isShutdown && errorNum == TRI_ERROR_QUERY_NOT_FOUND) {
|
if (isShutdown && errorNum == TRI_ERROR_QUERY_NOT_FOUND) {
|
||||||
|
|
|
@ -485,6 +485,9 @@ void ClusterFeature::start() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClusterFeature::beginShutdown() {
|
||||||
|
ClusterComm::instance()->disable();
|
||||||
|
}
|
||||||
|
|
||||||
void ClusterFeature::stop() {
|
void ClusterFeature::stop() {
|
||||||
|
|
||||||
|
@ -537,7 +540,6 @@ void ClusterFeature::unprepare() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_enableCluster) {
|
if (!_enableCluster) {
|
||||||
ClusterComm::instance()->disable();
|
|
||||||
ClusterComm::cleanup();
|
ClusterComm::cleanup();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ class ClusterFeature : public application_features::ApplicationFeature {
|
||||||
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
void validateOptions(std::shared_ptr<options::ProgramOptions>) override final;
|
||||||
void prepare() override final;
|
void prepare() override final;
|
||||||
void start() override final;
|
void start() override final;
|
||||||
|
void beginShutdown() override final;
|
||||||
void unprepare() override final;
|
void unprepare() override final;
|
||||||
|
|
||||||
std::string agencyPrefix() {
|
std::string agencyPrefix() {
|
||||||
|
|
Loading…
Reference in New Issue