1
0
Fork 0

Bug fix 3.5/fix view creation errors (#9599)

* Fix ArangoSearch view creation errors

* Fix another error
This commit is contained in:
KVS85 2019-07-29 20:41:51 +03:00 committed by GitHub
parent f995c46b71
commit 40c27d283e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View File

@ -166,14 +166,9 @@ void RestViewHandler::createView() {
return;
}
auto badParamError = [&]() -> void {
generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
"expecting body to be of the form {name: <string>, type: "
"<string>, properties: <object>}");
};
if (!body.isObject()) {
badParamError();
generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
"request body is not an object");
events::CreateView(_vocbase.name(), "", TRI_ERROR_BAD_PARAMETER);
return;
}
@ -181,10 +176,20 @@ void RestViewHandler::createView() {
auto nameSlice = body.get(StaticStrings::DataSourceName);
auto typeSlice = body.get(StaticStrings::DataSourceType);
if (!nameSlice.isString() || !typeSlice.isString()) {
badParamError();
if (!nameSlice.isString()) {
generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
"expecting name parameter to be of the form of \"name: "
"<string>\"");
events::CreateView(_vocbase.name(), "", TRI_ERROR_BAD_PARAMETER);
return;
}
if (!typeSlice.isString()) {
generateError(rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
"expecting type parameter to be of the form of \"type: "
"<string>\"");
events::CreateView(_vocbase.name(),
(nameSlice.isString() ? nameSlice.copyString() : ""),
nameSlice.copyString(),
TRI_ERROR_BAD_PARAMETER);
return;
}

View File

@ -44,7 +44,7 @@ struct InvalidViewFactory : public arangodb::ViewFactory {
return arangodb::Result(
TRI_ERROR_BAD_PARAMETER,
std::string(
"failure to create view without a factory for definition: ") +
"invalid type provided to create view with definition: ") +
definition.toString());
}
@ -54,7 +54,7 @@ struct InvalidViewFactory : public arangodb::ViewFactory {
return arangodb::Result(
TRI_ERROR_BAD_PARAMETER,
std::string(
"failure to instantiate view without a factory for definition: ") +
"invalid type provided to instantiate view with definition: ") +
definition.toString());
}
};