19
19
#include < cstring>
20
20
#include < sstream>
21
21
#include " session.h"
22
+ #include " errorcodes.h"
22
23
#include " uri_info.h"
23
24
#include " logging.h"
24
25
@@ -340,7 +341,8 @@ std::string Server::DispatchCommand(const std::string& uri,
340
341
341
342
if (command == webdriver::CommandType::NoCommand) {
342
343
// Hand-code the response for an unknown URL
343
- serialized_response.append (" { \" error\" : \" unknown method\" , " );
344
+ serialized_response.append (" { \" value\" : { " );
345
+ serialized_response.append (" \" error\" : \" unknown method\" , " );
344
346
serialized_response.append (" \" message\" : \" Command not found: " );
345
347
serialized_response.append (http_verb);
346
348
serialized_response.append (" " );
@@ -364,18 +366,23 @@ std::string Server::DispatchCommand(const std::string& uri,
364
366
serialized_response.append (" { \" value\" : null }" );
365
367
} else {
366
368
// Hand-code the response for an invalid session id
367
- serialized_response.append (" { \" error\" : \" invalid session id\" , " );
369
+ serialized_response.append (" { \" value\" : { " );
370
+ serialized_response.append (" \" error\" : \" " );
371
+ serialized_response.append (ERROR_INVALID_SESSION_ID).append (" \" , " );
368
372
serialized_response.append (" \" message\" : \" session " );
369
373
serialized_response.append (session_id);
370
- serialized_response.append (" does not exist\" }" );
374
+ serialized_response.append (" does not exist\" , " );
375
+ serialized_response.append (" \" stacktrace\" : \"\" }" );
376
+ serialized_response.append (" }" );
371
377
}
372
378
} else {
373
379
if (command == webdriver::CommandType::NewSession &&
374
380
this ->sessions_ .size () > 0 ) {
375
381
// According to the W3C Specification, only a single session is
376
382
// allowed by a single driver instance.
377
383
serialized_response.append (" { \" value\" : { " );
378
- serialized_response.append (" \" error\" : \" session not created\" , " );
384
+ serialized_response.append (" \" error\" : \" " );
385
+ serialized_response.append (ERROR_SESSION_NOT_CREATED).append (" \" , " );
379
386
serialized_response.append (" \" message\" : \" only one session may " );
380
387
serialized_response.append (" be created at a time, and a session " );
381
388
serialized_response.append (" already exists\" , " );
0 commit comments