1
0
Fork 0

attempt to fix release-3.4#98: Unsuccessful arangorestore needs better error message (#6949)

This commit is contained in:
Jan 2018-10-17 19:13:07 +02:00 committed by GitHub
parent b5ff5080ff
commit 285c1adb1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 6 deletions

View File

@ -27,6 +27,7 @@
#include <iostream>
#include <thread>
#include <velocypack/Builder.h>
#include <velocypack/Collection.h>
#include <velocypack/Iterator.h>
#include <velocypack/velocypack-aliases.h>
@ -82,9 +83,16 @@ arangodb::Result checkHttpResponse(
"got invalid response from server: " + client.getErrorMessage()};
}
if (response->wasHttpError()) {
return {TRI_ERROR_INTERNAL, "got invalid response from server: HTTP " +
itoa(response->getHttpReturnCode()) + ": " +
response->getHttpReturnMessage()};
int errorNum = TRI_ERROR_INTERNAL;
std::string errorMsg = response->getHttpReturnMessage();
std::shared_ptr<arangodb::velocypack::Builder> bodyBuilder(response->getBodyVelocyPack());
arangodb::velocypack::Slice error = bodyBuilder->slice();
if (!error.isNone() && error.hasKey(arangodb::StaticStrings::ErrorMessage)) {
errorNum = error.get(arangodb::StaticStrings::ErrorNum).getNumericValue<int>();
errorMsg = error.get(arangodb::StaticStrings::ErrorMessage).copyString();
}
return {errorNum, "got invalid response from server: HTTP " +
itoa(response->getHttpReturnCode()) + ": " + errorMsg};
}
return {TRI_ERROR_NO_ERROR};
}
@ -284,7 +292,7 @@ arangodb::Result dumpCollection(arangodb::httpclient::SimpleHttpClient& client,
}
if (!headerExtracted) { // NOT else, fallthrough from outer or inner above
return {TRI_ERROR_REPLICATION_INVALID_RESPONSE,
"got invalid response server: required header is missing"};
"got invalid response from server: required header is missing"};
}
// now actually write retrieved data to dump file

View File

@ -33,6 +33,7 @@
#include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/FileUtils.h"
#include "Basics/Result.h"
#include "Basics/StaticStrings.h"
#include "Basics/StringUtils.h"
#include "Basics/VelocyPackHelper.h"
#include "Logger/Logger.h"
@ -71,10 +72,18 @@ arangodb::Result checkHttpResponse(
};
}
if (response->wasHttpError()) {
return {TRI_ERROR_INTERNAL,
int errorNum = TRI_ERROR_INTERNAL;
std::string errorMsg = response->getHttpReturnMessage();
std::shared_ptr<arangodb::velocypack::Builder> bodyBuilder(response->getBodyVelocyPack());
arangodb::velocypack::Slice error = bodyBuilder->slice();
if (!error.isNone() && error.hasKey(arangodb::StaticStrings::ErrorMessage)) {
errorNum = error.get(arangodb::StaticStrings::ErrorNum).getNumericValue<int>();
errorMsg = error.get(arangodb::StaticStrings::ErrorMessage).copyString();
}
return {errorNum,
"got invalid response from server: HTTP " +
itoa(response->getHttpReturnCode()) + ": '" +
response->getHttpReturnMessage() +
errorMsg +
"' while executing '" +
requestAction +
"' with this payload: '" +