Chromium Code Reviews| Index: chrome/browser/devtools/devtools_protocol.cc |
| diff --git a/chrome/browser/devtools/devtools_protocol.cc b/chrome/browser/devtools/devtools_protocol.cc |
| index a22811053180c073bdcfd1f65072d176f448765c..8581d8b6279fd050ad9be9801d33dbe60bfb9ee1 100644 |
| --- a/chrome/browser/devtools/devtools_protocol.cc |
| +++ b/chrome/browser/devtools/devtools_protocol.cc |
| @@ -19,9 +19,7 @@ const char kParamsParam[] = "params"; |
| const char kResultParam[] = "result"; |
| // JSON RPC 2.0 spec: http://www.jsonrpc.org/specification#error_object |
| -enum Error { |
| - kErrorInvalidParams = -32602 |
| -}; |
| +enum Error { kErrorInvalidParams = -32602, kErrorServerError = -32000 }; |
| } // namespace |
| @@ -46,6 +44,7 @@ std::unique_ptr<base::DictionaryValue> |
| DevToolsProtocol::CreateInvalidParamsResponse(int command_id, |
| const std::string& param) { |
| std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue()); |
| + response->SetInteger(kIdParam, command_id); |
|
dgozman
2017/03/22 21:28:34
Nice catch! Thanks.
|
| base::DictionaryValue* error_object = new base::DictionaryValue(); |
| response->Set(kErrorParam, error_object); |
| error_object->SetInteger(kErrorCodeParam, kErrorInvalidParams); |
| @@ -56,6 +55,19 @@ DevToolsProtocol::CreateInvalidParamsResponse(int command_id, |
| } |
| // static |
| +std::unique_ptr<base::DictionaryValue> DevToolsProtocol::CreateErrorResponse( |
| + int command_id, |
| + const std::string& error_message) { |
| + std::unique_ptr<base::DictionaryValue> response(new base::DictionaryValue()); |
| + response->SetInteger(kIdParam, command_id); |
| + base::DictionaryValue* error_object = new base::DictionaryValue(); |
| + response->Set(kErrorParam, error_object); |
| + error_object->SetInteger(kErrorCodeParam, kErrorServerError); |
| + error_object->SetString(kErrorMessageParam, error_message); |
| + return response; |
| +} |
| + |
| +// static |
| std::unique_ptr<base::DictionaryValue> DevToolsProtocol::CreateSuccessResponse( |
| int command_id, |
| std::unique_ptr<base::DictionaryValue> result) { |