@@ -166,25 +166,30 @@ void RestViewHandler::createView() {
166
166
return ;
167
167
}
168
168
169
- auto badParamError = [&]() -> void {
170
- generateError (rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
171
- " expecting body to be of the form {name: <string>, type: "
172
- " <string>, properties: <object>}" );
173
- };
174
-
175
169
if (!body.isObject ()) {
176
- badParamError ();
170
+ generateError (rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
171
+ " request body is not an object" );
177
172
events::CreateView (_vocbase.name (), " " , TRI_ERROR_BAD_PARAMETER);
178
173
return ;
179
174
}
180
175
181
176
auto nameSlice = body.get (StaticStrings::DataSourceName);
182
177
auto typeSlice = body.get (StaticStrings::DataSourceType);
183
178
184
- if (!nameSlice.isString () || !typeSlice.isString ()) {
185
- badParamError ();
179
+ if (!nameSlice.isString ()) {
180
+ generateError (rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
181
+ " expecting name parameter to be of the form of \" name: "
182
+ " <string>\" " );
183
+ events::CreateView (_vocbase.name (), " " , TRI_ERROR_BAD_PARAMETER);
184
+ return ;
185
+ }
186
+
187
+ if (!typeSlice.isString ()) {
188
+ generateError (rest::ResponseCode::BAD, TRI_ERROR_BAD_PARAMETER,
189
+ " expecting type parameter to be of the form of \" type: "
190
+ " <string>\" " );
186 191
events::CreateView (_vocbase.name (),
187
- ( nameSlice.isString () ? nameSlice. copyString () : " " ),
192
+ nameSlice.copyString (),
188
193
TRI_ERROR_BAD_PARAMETER);
189
194
return ;
190
195
}
0 commit comments