Changeset 90110 in webkit
- Timestamp:
- Jun 30, 2011, 6:22:29 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r90104 r90110 1 2011-06-30 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: Protocol: error object needs some improvement. 6 https://bugs.webkit.org/show_bug.cgi?id=63707 7 8 Current implementation is not useful in the code. 9 We need to have toString implementation with nice formatting 10 I'd like to use error.message property as the main place for the error's text. 11 12 * inspector/elements/set-attribute.html: 13 * inspector/report-protocol-errors-expected.txt: 14 * inspector/report-protocol-errors.html: 15 1 16 2011-06-30 Philippe Normand <pnormand@igalia.com> 2 17 -
trunk/LayoutTests/inspector/elements/set-attribute.html
r90013 r90110 103 103 function callback(error) 104 104 { 105 InspectorTest.addResult("Error: " + error. data[0]);105 InspectorTest.addResult("Error: " + error.getMessage()); 106 106 WebInspector.domAgent.removeEventListener(WebInspector.DOMAgent.Events.AttrModified, callback); 107 107 InspectorTest.addResult("=== Set malformed attribute as text ==="); -
trunk/LayoutTests/inspector/report-protocol-errors-expected.txt
r88535 r90110 4 4 error : { 5 5 code : -32700 6 message : "Parse error." 7 data : [ 8 "Message should be in JSON format." 9 ] 6 message : "Message should be in JSON format" 10 7 } 11 8 id : null 12 9 } 10 error.code: -32700 11 error.getMessage(): Message should be in JSON format 12 error.toString(): Parse error(-32700): Message should be in JSON format. 13 ------------------------------------------------------- 13 14 { 14 15 error : { 15 16 code : -32600 16 message : "Invalid Request." 17 data : [ 18 "Invalid message format. 'id' property was not found in the request." 19 ] 17 message : "'id' property was not found" 20 18 } 21 19 id : null 22 20 } 21 error.code: -32600 22 error.getMessage(): 'id' property was not found 23 error.toString(): Invalid Request(-32600): 'id' property was not found. 24 ------------------------------------------------------- 23 25 { 24 26 error : { 25 27 code : -32600 26 message : "Invalid Request." 27 data : [ 28 "Invalid message format. The type of 'id' property should be number." 29 ] 28 message : "The type of 'id' property should be number" 30 29 } 31 30 id : null 32 31 } 32 error.code: -32600 33 error.getMessage(): The type of 'id' property should be number 34 error.toString(): Invalid Request(-32600): The type of 'id' property should be number. 35 ------------------------------------------------------- 33 36 { 34 37 error : { 35 38 code : -32600 36 message : "Invalid Request." 37 data : [ 38 "Invalid message format. The type of 'method' property should be string." 39 ] 39 message : "The type of 'method' property should be string" 40 40 } 41 41 id : 1 42 42 } 43 { 44 error : { 45 code : -32601 46 message : "Method not found." 47 data : [ 48 "Invalid method name was received. 'resourceContent' wasn't found." 49 ] 43 error.code: -32600 44 error.getMessage(): The type of 'method' property should be string 45 error.toString(): Invalid Request(-32600): The type of 'method' property should be string. 46 ------------------------------------------------------- 47 { 48 error : { 49 code : -32601 50 message : "'resourceContent' wasn't found" 50 51 } 51 52 id : 2 52 53 } 53 { 54 error : { 55 code : -32601 56 message : "Method not found." 57 data : [ 58 "Invalid method name was received. 'DOM.test' wasn't found." 59 ] 54 error.code: -32601 55 error.getMessage(): 'resourceContent' wasn't found 56 error.toString(): Method not found(-32601): 'resourceContent' wasn't found. 57 ------------------------------------------------------- 58 { 59 error : { 60 code : -32601 61 message : "'DOM.test' wasn't found" 60 62 } 61 63 id : 3 62 64 } 63 { 64 error : { 65 code : -32602 66 message : "Invalid params." 65 error.code: -32601 66 error.getMessage(): 'DOM.test' wasn't found 67 error.toString(): Method not found(-32601): 'DOM.test' wasn't found. 68 ------------------------------------------------------- 69 { 70 error : { 71 code : -32602 72 message : "Some arguments of method 'Page.getResourceContent' can't be processed" 67 73 data : [ 68 74 "'params' property with type 'object' was not found." … … 71 77 id : 4 72 78 } 73 { 74 error : { 75 code : -32602 76 message : "Invalid params." 79 error.code: -32602 80 error.getMessage(): Some arguments of method 'Page.getResourceContent' can't be processed 81 error.toString(): Invalid params(-32602): Some arguments of method 'Page.getResourceContent' can't be processed. 'params' property with type 'object' was not found. 82 ------------------------------------------------------- 83 { 84 error : { 85 code : -32602 86 message : "Some arguments of method 'Page.getResourceContent' can't be processed" 77 87 data : [ 78 88 "'params' property with type 'object' was not found." … … 81 91 id : 5 82 92 } 83 { 84 error : { 85 code : -32602 86 message : "Invalid params." 93 error.code: -32602 94 error.getMessage(): Some arguments of method 'Page.getResourceContent' can't be processed 95 error.toString(): Invalid params(-32602): Some arguments of method 'Page.getResourceContent' can't be processed. 'params' property with type 'object' was not found. 96 ------------------------------------------------------- 97 { 98 error : { 99 code : -32602 100 message : "Some arguments of method 'Page.getResourceContent' can't be processed" 87 101 data : [ 88 102 "Parameter 'frameId' with type 'String' was not found." … … 92 106 id : 6 93 107 } 94 { 95 error : { 96 code : -32602 97 message : "Invalid params." 108 error.code: -32602 109 error.getMessage(): Some arguments of method 'Page.getResourceContent' can't be processed 110 error.toString(): Invalid params(-32602): Some arguments of method 'Page.getResourceContent' can't be processed. Parameter 'frameId' with type 'String' was not found. Parameter 'url' with type 'String' was not found. 111 ------------------------------------------------------- 112 { 113 error : { 114 code : -32602 115 message : "Some arguments of method 'Page.getResourceContent' can't be processed" 98 116 data : [ 99 117 "Parameter 'url' with type 'String' was not found." … … 102 120 id : 7 103 121 } 104 { 105 error : { 106 code : -32601 107 message : "Method not found." 108 data : [ 109 "Invalid method name was received. 'Page.test' wasn't found." 110 ] 122 error.code: -32602 123 error.getMessage(): Some arguments of method 'Page.getResourceContent' can't be processed 124 error.toString(): Invalid params(-32602): Some arguments of method 'Page.getResourceContent' can't be processed. Parameter 'url' with type 'String' was not found. 125 ------------------------------------------------------- 126 { 127 error : { 128 code : -32601 129 message : "'Page.test' wasn't found" 111 130 } 112 131 id : 8 113 132 } 114 { 115 error : { 116 code : -32601 117 message : "Method not found." 118 data : [ 119 "Invalid method name was received. 'Page.test' wasn't found." 120 ] 133 error.code: -32601 134 error.getMessage(): 'Page.test' wasn't found 135 error.toString(): Method not found(-32601): 'Page.test' wasn't found. 136 ------------------------------------------------------- 137 { 138 error : { 139 code : -32601 140 message : "'Page.test' wasn't found" 121 141 } 122 142 id : 9 123 143 } 124 { 125 error : { 126 code : -32601 127 message : "Method not found." 128 data : [ 129 "Invalid method name was received. 'Page.test' wasn't found." 130 ] 144 error.code: -32601 145 error.getMessage(): 'Page.test' wasn't found 146 error.toString(): Method not found(-32601): 'Page.test' wasn't found. 147 ------------------------------------------------------- 148 { 149 error : { 150 code : -32601 151 message : "'Page.test' wasn't found" 131 152 } 132 153 id : 10 133 154 } 134 { 135 error : { 136 code : -32601 137 message : "Method not found." 138 data : [ 139 "Invalid method name was received. 'Page.test' wasn't found." 140 ] 155 error.code: -32601 156 error.getMessage(): 'Page.test' wasn't found 157 error.toString(): Method not found(-32601): 'Page.test' wasn't found. 158 ------------------------------------------------------- 159 { 160 error : { 161 code : -32601 162 message : "'Page.test' wasn't found" 141 163 } 142 164 id : 11 143 165 } 144 { 145 error : { 146 code : -32601 147 message : "Method not found." 148 data : [ 149 "Invalid method name was received. 'Page.test' wasn't found." 150 ] 166 error.code: -32601 167 error.getMessage(): 'Page.test' wasn't found 168 error.toString(): Method not found(-32601): 'Page.test' wasn't found. 169 ------------------------------------------------------- 170 { 171 error : { 172 code : -32601 173 message : "'Page.test' wasn't found" 151 174 } 152 175 id : 12 153 176 } 154 { 155 error : { 156 code : -32601 157 message : "Method not found." 158 data : [ 159 "Invalid method name was received. 'Page.test' wasn't found." 160 ] 177 error.code: -32601 178 error.getMessage(): 'Page.test' wasn't found 179 error.toString(): Method not found(-32601): 'Page.test' wasn't found. 180 ------------------------------------------------------- 181 { 182 error : { 183 code : -32601 184 message : "'Page.test' wasn't found" 161 185 } 162 186 id : 13 163 187 } 164 { 165 error : { 166 code : -32601 167 message : "Method not found." 168 data : [ 169 "Invalid method name was received. 'Page.test' wasn't found." 170 ] 188 error.code: -32601 189 error.getMessage(): 'Page.test' wasn't found 190 error.toString(): Method not found(-32601): 'Page.test' wasn't found. 191 ------------------------------------------------------- 192 { 193 error : { 194 code : -32601 195 message : "'Page.test' wasn't found" 171 196 } 172 197 id : 14 173 198 } 174 { 175 error : { 176 code : -32601 177 message : "Method not found." 178 data : [ 179 "Invalid method name was received. 'Page.test' wasn't found." 180 ] 199 error.code: -32601 200 error.getMessage(): 'Page.test' wasn't found 201 error.toString(): Method not found(-32601): 'Page.test' wasn't found. 202 ------------------------------------------------------- 203 { 204 error : { 205 code : -32601 206 message : "'Page.test' wasn't found" 181 207 } 182 208 id : 15 183 209 } 184 { 185 error : { 186 code : -32601 187 message : "Method not found." 188 data : [ 189 "Invalid method name was received. 'Page.test' wasn't found." 190 ] 210 error.code: -32601 211 error.getMessage(): 'Page.test' wasn't found 212 error.toString(): Method not found(-32601): 'Page.test' wasn't found. 213 ------------------------------------------------------- 214 { 215 error : { 216 code : -32601 217 message : "'Page.test' wasn't found" 191 218 } 192 219 id : 16 193 220 } 221 error.code: -32601 222 error.getMessage(): 'Page.test' wasn't found 223 error.toString(): Method not found(-32601): 'Page.test' wasn't found. 224 ------------------------------------------------------- 194 225 -
trunk/LayoutTests/inspector/report-protocol-errors.html
r88535 r90110 31 31 InspectorBackend.reportProtocolError = function(message) 32 32 { 33 if (numberOfReports < messages.length) 33 34 if (numberOfReports < messages.length) { 34 35 InspectorTest.addObject(message); 36 InspectorTest.addResult("error.code: " + message.error.code); 37 InspectorTest.addResult("error.getMessage(): " + message.error.getMessage()); 38 InspectorTest.addResult("error.toString(): " + message.error); 39 InspectorTest.addResult("-------------------------------------------------------"); 40 } 35 41 36 42 if (++numberOfReports === messages.length) -
trunk/Source/WebCore/ChangeLog
r90107 r90110 1 2011-06-30 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Reviewed by Pavel Feldman. 4 5 Web Inspector: Protocol: error object needs some improvement. 6 https://bugs.webkit.org/show_bug.cgi?id=63707 7 8 Current implementation is not useful in the code. 9 We need to have toString implementation with nice formatting 10 I'd like to use error.message property as the main place for the error's text. 11 12 * inspector/CodeGeneratorInspector.pm: 13 1 14 2011-06-30 Mikhail Naganov <mnaganov@chromium.org> 2 15 -
trunk/Source/WebCore/inspector/CodeGeneratorInspector.pm
r87146 r90110 499 499 push(@function, " }"); 500 500 } 501 push(@function, " sendResponse(callId, result, protocolErrors, error);");501 push(@function, " sendResponse(callId, result, String::format(s_argumentsErrorTemplate, \"$fullQualifiedFunctionNameDot\"), protocolErrors, error);"); 502 502 push(@function, "}"); 503 503 push(@function, ""); … … 509 509 my $sendResponse = << "EOF"; 510 510 511 void ${backendClassName}::sendResponse(long callId, PassRefPtr<InspectorObject> result, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError)511 void ${backendClassName}::sendResponse(long callId, PassRefPtr<InspectorObject> result, const String& errorMessage, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError) 512 512 { 513 513 if (protocolErrors->length()) { 514 reportProtocolError(&callId, InvalidParams, protocolErrors);514 reportProtocolError(&callId, InvalidParams, errorMessage, protocolErrors); 515 515 return; 516 516 } … … 534 534 my $reportProtocolError = << "EOF"; 535 535 536 void ${backendClassName}::reportProtocolError(const long* const callId, CommonErrorCode code, const String& customText) const 537 { 538 RefPtr<InspectorArray> data = InspectorArray::create(); 539 data->pushString(customText); 540 reportProtocolError(callId, code, data.release()); 541 } 542 543 void ${backendClassName}::reportProtocolError(const long* const callId, CommonErrorCode code, PassRefPtr<InspectorArray> data) const 544 { 545 DEFINE_STATIC_LOCAL(Vector<String>,s_commonErrors,); 536 void ${backendClassName}::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage) const 537 { 538 reportProtocolError(callId, code, errorMessage, 0); 539 } 540 541 void ${backendClassName}::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage, PassRefPtr<InspectorArray> data) const 542 { 543 DEFINE_STATIC_LOCAL(Vector<int>,s_commonErrors,); 546 544 if (!s_commonErrors.size()) { 547 s_commonErrors.insert(ParseError, "{\\\"code\\\":-32700,\\\"message\\\":\\\"Parse error.\\\"}");548 s_commonErrors.insert(InvalidRequest, "{\\\"code\\\":-32600,\\\"message\\\":\\\"Invalid Request.\\\"}");549 s_commonErrors.insert(MethodNotFound, "{\\\"code\\\":-32601,\\\"message\\\":\\\"Method not found.\\\"}");550 s_commonErrors.insert(InvalidParams, "{\\\"code\\\":-32602,\\\"message\\\":\\\"Invalid params.\\\"}");551 s_commonErrors.insert(InternalError, "{\\\"code\\\":-32603,\\\"message\\\":\\\"Internal error.\\\"}");552 s_commonErrors.insert(ServerError, "{\\\"code\\\":-32000,\\\"message\\\":\\\"Server error.\\\"}");545 s_commonErrors.insert(ParseError, -32700); 546 s_commonErrors.insert(InvalidRequest, -32600); 547 s_commonErrors.insert(MethodNotFound, -32601); 548 s_commonErrors.insert(InvalidParams, -32602); 549 s_commonErrors.insert(InternalError, -32603); 550 s_commonErrors.insert(ServerError, -32000); 553 551 } 554 552 ASSERT(code >=0); 555 553 ASSERT((unsigned)code < s_commonErrors.size()); 556 554 ASSERT(s_commonErrors[code]); 557 ASSERT(InspectorObject::parseJSON(s_commonErrors[code])); 558 RefPtr<InspectorObject> error = InspectorObject::parseJSON(s_commonErrors[code])->asObject(); 555 RefPtr<InspectorObject> error = InspectorObject::create(); 556 error->setNumber("code", s_commonErrors[code]); 557 error->setString("message", errorMessage); 559 558 ASSERT(error); 560 error->setArray("data", data); 559 if (data) 560 error->setArray("data", data); 561 561 RefPtr<InspectorObject> message = InspectorObject::create(); 562 562 message->setObject("error", error); … … 634 634 RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message); 635 635 if (!parsedMessage) { 636 reportProtocolError(0, ParseError, "Message should be in JSON format .");636 reportProtocolError(0, ParseError, "Message should be in JSON format"); 637 637 return; 638 638 } … … 640 640 RefPtr<InspectorObject> messageObject = parsedMessage->asObject(); 641 641 if (!messageObject) { 642 reportProtocolError(0, InvalidRequest, " Invalid message format. The message should be a JSONified object.");642 reportProtocolError(0, InvalidRequest, "Message should be a JSONified object"); 643 643 return; 644 644 } … … 646 646 RefPtr<InspectorValue> callIdValue = messageObject->get("id"); 647 647 if (!callIdValue) { 648 reportProtocolError(0, InvalidRequest, " Invalid message format. 'id' property was not found in the request.");648 reportProtocolError(0, InvalidRequest, "'id' property was not found"); 649 649 return; 650 650 } 651 651 652 652 if (!callIdValue->asNumber(&callId)) { 653 reportProtocolError(0, InvalidRequest, " Invalid message format. The type of 'id' property should be number.");653 reportProtocolError(0, InvalidRequest, "The type of 'id' property should be number"); 654 654 return; 655 655 } … … 657 657 RefPtr<InspectorValue> methodValue = messageObject->get("method"); 658 658 if (!methodValue) { 659 reportProtocolError(&callId, InvalidRequest, " Invalid message format. 'method' property wasn't found.");659 reportProtocolError(&callId, InvalidRequest, "'method' property wasn't found"); 660 660 return; 661 661 } … … 663 663 String method; 664 664 if (!methodValue->asString(&method)) { 665 reportProtocolError(&callId, InvalidRequest, " Invalid message format. The type of 'method' property should be string.");665 reportProtocolError(&callId, InvalidRequest, "The type of 'method' property should be string"); 666 666 return; 667 667 } … … 669 669 HashMap<String, CallHandler>::iterator it = dispatchMap.find(method); 670 670 if (it == dispatchMap.end()) { 671 reportProtocolError(&callId, MethodNotFound, " Invalid method name was received. '" + method + "' wasn't found.");671 reportProtocolError(&callId, MethodNotFound, "'" + method + "' wasn't found"); 672 672 return; 673 673 } … … 841 841 842 842 if ("id" in messageObject) { // just a response for some request 843 if (messageObject.error && messageObject.error.code !== -32000) 844 this.reportProtocolError(messageObject); 843 if (messageObject.error) { 844 messageObject.error.__proto__ = { 845 getDescription: function() 846 { 847 switch(this.code) { 848 case -32700: return "Parse error"; 849 case -32600: return "Invalid Request"; 850 case -32601: return "Method not found"; 851 case -32602: return "Invalid params"; 852 case -32603: return "Internal error";; 853 case -32000: return "Server error"; 854 } 855 }, 856 857 toString: function() 858 { 859 var description ="Unknown error code"; 860 return this.getDescription() + "(" + this.code + "): " + this.message + "." + (this.data ? " " + this.data.join(" ") : ""); 861 }, 862 863 getMessage: function() 864 { 865 return this.message; 866 } 867 } 868 869 if (messageObject.error.code !== -32000) 870 this.reportProtocolError(messageObject); 871 } 845 872 846 873 var arguments = []; … … 1052 1079 push(@backendHead, " };"); 1053 1080 push(@backendHead, ""); 1054 push(@backendHead, " void reportProtocolError(const long* const callId, CommonErrorCode, const String& error Text) const;");1055 push(@backendHead, " void reportProtocolError(const long* const callId, CommonErrorCode, PassRefPtr<InspectorArray> data) const;");1081 push(@backendHead, " void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage) const;"); 1082 push(@backendHead, " void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage, PassRefPtr<InspectorArray> data) const;"); 1056 1083 push(@backendHead, " void dispatch(const String& message);"); 1057 1084 push(@backendHead, " static bool getCommandName(const String& message, String* result);"); … … 1082 1109 unshift(@backendConstantDefinitions, "const char* InspectorBackendDispatcher::commandNames[] = {"); 1083 1110 push(@backendConstantDefinitions, "};"); 1111 push(@backendConstantDefinitions, ""); 1112 push(@backendConstantDefinitions, "static const char* s_argumentsErrorTemplate = \"Some arguments of method '%s' can't be processed\";"); 1084 1113 1085 1114 # Make dispatcher methods private on the backend. … … 1096 1125 } 1097 1126 1098 push(@backendConstantDeclarations, " void sendResponse(long callId, PassRefPtr<InspectorObject> result, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError);");1127 push(@backendConstantDeclarations, " void sendResponse(long callId, PassRefPtr<InspectorObject> result, const String& errorMessage, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError);"); 1099 1128 1100 1129 generateBackendAgentFieldsAndConstructor();
Note:
See TracChangeset
for help on using the changeset viewer.