Skip to content
This repository was archived by the owner on Jun 18, 2020. It is now read-only.

Commit b52f9c3

Browse files
Fixed bug where trying to get a key from a velocypack array would crash the driver
1 parent 6e8bd2e commit b52f9c3

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/connection.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,20 @@ namespace arangodb { namespace fuerte { namespace php {
113113

114114
auto response = new Response(*result);
115115

116+
bool failure = false;
117+
if(response->getFuerteResponse()->slices().front().isObject()) {
118+
failure = response->getFuerteResponse()->slices().front().get("error").getBool();
119+
}
120+
116121
auto statusCode = response->getHttpCode();
117-
if((!(statusCode >= 200 && statusCode <= 299))/* || response->getFuerteResponse()->slices().front().get("error").getBool()*/) {
118-
throwRequestFailedException("This is the error message", statusCode, response->getBody());
122+
if((!(statusCode >= 200 && statusCode <= 299)) || failure) {
123+
std::string errorMessage = "Response contains an error";
124+
125+
if(response->getFuerteResponse()->slices().front().isObject()) {
126+
errorMessage = response->getFuerteResponse()->slices().front().get("errorMessage").copyString();
127+
}
128+
129+
throwRequestFailedException(errorMessage.c_str(), statusCode, response->getBody());
119130
}
120131

121132
return response;

0 commit comments

Comments
 (0)