Log Message
2011-06-30 Ilya Tikhonovsky <[email protected]> Reviewed by Pavel Feldman.
Web Inspector: Protocol: error object needs some improvement.
https://bugs.webkit.org/show_bug.cgi?id=63707
Current implementation is not useful in the code.
We need to have toString implementation with nice formatting
I'd like to use error.message property as the main place for the error's text.
* inspector/elements/set-attribute.html:
* inspector/report-protocol-errors-expected.txt:
* inspector/report-protocol-errors.html:
2011-06-30 Ilya Tikhonovsky <[email protected]>
Reviewed by Pavel Feldman.
Web Inspector: Protocol: error object needs some improvement.
https://bugs.webkit.org/show_bug.cgi?id=63707
Current implementation is not useful in the code.
We need to have toString implementation with nice formatting
I'd like to use error.message property as the main place for the error's text.
* inspector/CodeGeneratorInspector.pm:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (90109 => 90110)
--- trunk/LayoutTests/ChangeLog 2011-06-30 13:02:47 UTC (rev 90109)
+++ trunk/LayoutTests/ChangeLog 2011-06-30 13:22:29 UTC (rev 90110)
@@ -1,3 +1,18 @@
+2011-06-30 Ilya Tikhonovsky <[email protected]>
+
+ Reviewed by Pavel Feldman.
+
+ Web Inspector: Protocol: error object needs some improvement.
+ https://bugs.webkit.org/show_bug.cgi?id=63707
+
+ Current implementation is not useful in the code.
+ We need to have toString implementation with nice formatting
+ I'd like to use error.message property as the main place for the error's text.
+
+ * inspector/elements/set-attribute.html:
+ * inspector/report-protocol-errors-expected.txt:
+ * inspector/report-protocol-errors.html:
+
2011-06-30 Philippe Normand <[email protected]>
Unreviewed, skip a failing media test on GTK because of
Modified: trunk/LayoutTests/inspector/elements/set-attribute.html (90109 => 90110)
--- trunk/LayoutTests/inspector/elements/set-attribute.html 2011-06-30 13:02:47 UTC (rev 90109)
+++ trunk/LayoutTests/inspector/elements/set-attribute.html 2011-06-30 13:22:29 UTC (rev 90110)
@@ -102,7 +102,7 @@
{
function callback(error)
{
- InspectorTest.addResult("Error: " + error.data[0]);
+ InspectorTest.addResult("Error: " + error.getMessage());
WebInspector.domAgent.removeEventListener(WebInspector.DOMAgent.Events.AttrModified, callback);
InspectorTest.addResult("=== Set malformed attribute as text ===");
InspectorTest.dumpElementsTree(targetNode);
Modified: trunk/LayoutTests/inspector/report-protocol-errors-expected.txt (90109 => 90110)
--- trunk/LayoutTests/inspector/report-protocol-errors-expected.txt 2011-06-30 13:02:47 UTC (rev 90109)
+++ trunk/LayoutTests/inspector/report-protocol-errors-expected.txt 2011-06-30 13:22:29 UTC (rev 90110)
@@ -3,87 +3,101 @@
{
error : {
code : -32700
- message : "Parse error."
- data : [
- "Message should be in JSON format."
- ]
+ message : "Message should be in JSON format"
}
id : null
}
+error.code: -32700
+error.getMessage(): Message should be in JSON format
+error.toString(): Parse error(-32700): Message should be in JSON format.
+-------------------------------------------------------
{
error : {
code : -32600
- message : "Invalid Request."
- data : [
- "Invalid message format. 'id' property was not found in the request."
- ]
+ message : "'id' property was not found"
}
id : null
}
+error.code: -32600
+error.getMessage(): 'id' property was not found
+error.toString(): Invalid Request(-32600): 'id' property was not found.
+-------------------------------------------------------
{
error : {
code : -32600
- message : "Invalid Request."
- data : [
- "Invalid message format. The type of 'id' property should be number."
- ]
+ message : "The type of 'id' property should be number"
}
id : null
}
+error.code: -32600
+error.getMessage(): The type of 'id' property should be number
+error.toString(): Invalid Request(-32600): The type of 'id' property should be number.
+-------------------------------------------------------
{
error : {
code : -32600
- message : "Invalid Request."
- data : [
- "Invalid message format. The type of 'method' property should be string."
- ]
+ message : "The type of 'method' property should be string"
}
id : 1
}
+error.code: -32600
+error.getMessage(): The type of 'method' property should be string
+error.toString(): Invalid Request(-32600): The type of 'method' property should be string.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'resourceContent' wasn't found."
- ]
+ message : "'resourceContent' wasn't found"
}
id : 2
}
+error.code: -32601
+error.getMessage(): 'resourceContent' wasn't found
+error.toString(): Method not found(-32601): 'resourceContent' wasn't found.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'DOM.test' wasn't found."
- ]
+ message : "'DOM.test' wasn't found"
}
id : 3
}
+error.code: -32601
+error.getMessage(): 'DOM.test' wasn't found
+error.toString(): Method not found(-32601): 'DOM.test' wasn't found.
+-------------------------------------------------------
{
error : {
code : -32602
- message : "Invalid params."
+ message : "Some arguments of method 'Page.getResourceContent' can't be processed"
data : [
"'params' property with type 'object' was not found."
]
}
id : 4
}
+error.code: -32602
+error.getMessage(): Some arguments of method 'Page.getResourceContent' can't be processed
+error.toString(): Invalid params(-32602): Some arguments of method 'Page.getResourceContent' can't be processed. 'params' property with type 'object' was not found.
+-------------------------------------------------------
{
error : {
code : -32602
- message : "Invalid params."
+ message : "Some arguments of method 'Page.getResourceContent' can't be processed"
data : [
"'params' property with type 'object' was not found."
]
}
id : 5
}
+error.code: -32602
+error.getMessage(): Some arguments of method 'Page.getResourceContent' can't be processed
+error.toString(): Invalid params(-32602): Some arguments of method 'Page.getResourceContent' can't be processed. 'params' property with type 'object' was not found.
+-------------------------------------------------------
{
error : {
code : -32602
- message : "Invalid params."
+ message : "Some arguments of method 'Page.getResourceContent' can't be processed"
data : [
"Parameter 'frameId' with type 'String' was not found."
"Parameter 'url' with type 'String' was not found."
@@ -91,104 +105,121 @@
}
id : 6
}
+error.code: -32602
+error.getMessage(): Some arguments of method 'Page.getResourceContent' can't be processed
+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.
+-------------------------------------------------------
{
error : {
code : -32602
- message : "Invalid params."
+ message : "Some arguments of method 'Page.getResourceContent' can't be processed"
data : [
"Parameter 'url' with type 'String' was not found."
]
}
id : 7
}
+error.code: -32602
+error.getMessage(): Some arguments of method 'Page.getResourceContent' can't be processed
+error.toString(): Invalid params(-32602): Some arguments of method 'Page.getResourceContent' can't be processed. Parameter 'url' with type 'String' was not found.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'Page.test' wasn't found."
- ]
+ message : "'Page.test' wasn't found"
}
id : 8
}
+error.code: -32601
+error.getMessage(): 'Page.test' wasn't found
+error.toString(): Method not found(-32601): 'Page.test' wasn't found.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'Page.test' wasn't found."
- ]
+ message : "'Page.test' wasn't found"
}
id : 9
}
+error.code: -32601
+error.getMessage(): 'Page.test' wasn't found
+error.toString(): Method not found(-32601): 'Page.test' wasn't found.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'Page.test' wasn't found."
- ]
+ message : "'Page.test' wasn't found"
}
id : 10
}
+error.code: -32601
+error.getMessage(): 'Page.test' wasn't found
+error.toString(): Method not found(-32601): 'Page.test' wasn't found.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'Page.test' wasn't found."
- ]
+ message : "'Page.test' wasn't found"
}
id : 11
}
+error.code: -32601
+error.getMessage(): 'Page.test' wasn't found
+error.toString(): Method not found(-32601): 'Page.test' wasn't found.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'Page.test' wasn't found."
- ]
+ message : "'Page.test' wasn't found"
}
id : 12
}
+error.code: -32601
+error.getMessage(): 'Page.test' wasn't found
+error.toString(): Method not found(-32601): 'Page.test' wasn't found.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'Page.test' wasn't found."
- ]
+ message : "'Page.test' wasn't found"
}
id : 13
}
+error.code: -32601
+error.getMessage(): 'Page.test' wasn't found
+error.toString(): Method not found(-32601): 'Page.test' wasn't found.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'Page.test' wasn't found."
- ]
+ message : "'Page.test' wasn't found"
}
id : 14
}
+error.code: -32601
+error.getMessage(): 'Page.test' wasn't found
+error.toString(): Method not found(-32601): 'Page.test' wasn't found.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'Page.test' wasn't found."
- ]
+ message : "'Page.test' wasn't found"
}
id : 15
}
+error.code: -32601
+error.getMessage(): 'Page.test' wasn't found
+error.toString(): Method not found(-32601): 'Page.test' wasn't found.
+-------------------------------------------------------
{
error : {
code : -32601
- message : "Method not found."
- data : [
- "Invalid method name was received. 'Page.test' wasn't found."
- ]
+ message : "'Page.test' wasn't found"
}
id : 16
}
+error.code: -32601
+error.getMessage(): 'Page.test' wasn't found
+error.toString(): Method not found(-32601): 'Page.test' wasn't found.
+-------------------------------------------------------
Modified: trunk/LayoutTests/inspector/report-protocol-errors.html (90109 => 90110)
--- trunk/LayoutTests/inspector/report-protocol-errors.html 2011-06-30 13:02:47 UTC (rev 90109)
+++ trunk/LayoutTests/inspector/report-protocol-errors.html 2011-06-30 13:22:29 UTC (rev 90110)
@@ -30,8 +30,14 @@
InspectorBackend.reportProtocolError = function(message)
{
- if (numberOfReports < messages.length)
+
+ if (numberOfReports < messages.length) {
InspectorTest.addObject(message);
+ InspectorTest.addResult("error.code: " + message.error.code);
+ InspectorTest.addResult("error.getMessage(): " + message.error.getMessage());
+ InspectorTest.addResult("error.toString(): " + message.error);
+ InspectorTest.addResult("-------------------------------------------------------");
+ }
if (++numberOfReports === messages.length)
InspectorTest.completeTest();
Modified: trunk/Source/WebCore/ChangeLog (90109 => 90110)
--- trunk/Source/WebCore/ChangeLog 2011-06-30 13:02:47 UTC (rev 90109)
+++ trunk/Source/WebCore/ChangeLog 2011-06-30 13:22:29 UTC (rev 90110)
@@ -1,3 +1,16 @@
+2011-06-30 Ilya Tikhonovsky <[email protected]>
+
+ Reviewed by Pavel Feldman.
+
+ Web Inspector: Protocol: error object needs some improvement.
+ https://bugs.webkit.org/show_bug.cgi?id=63707
+
+ Current implementation is not useful in the code.
+ We need to have toString implementation with nice formatting
+ I'd like to use error.message property as the main place for the error's text.
+
+ * inspector/CodeGeneratorInspector.pm:
+
2011-06-30 Mikhail Naganov <[email protected]>
Reviewed by Yury Semikhatsky.
Modified: trunk/Source/WebCore/inspector/CodeGeneratorInspector.pm (90109 => 90110)
--- trunk/Source/WebCore/inspector/CodeGeneratorInspector.pm 2011-06-30 13:02:47 UTC (rev 90109)
+++ trunk/Source/WebCore/inspector/CodeGeneratorInspector.pm 2011-06-30 13:22:29 UTC (rev 90110)
@@ -498,7 +498,7 @@
}
push(@function, " }");
}
- push(@function, " sendResponse(callId, result, protocolErrors, error);");
+ push(@function, " sendResponse(callId, result, String::format(s_argumentsErrorTemplate, \"$fullQualifiedFunctionNameDot\"), protocolErrors, error);");
push(@function, "}");
push(@function, "");
push(@backendMethodsImpl, @function);
@@ -508,10 +508,10 @@
{
my $sendResponse = << "EOF";
-void ${backendClassName}::sendResponse(long callId, PassRefPtr<InspectorObject> result, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError)
+void ${backendClassName}::sendResponse(long callId, PassRefPtr<InspectorObject> result, const String& errorMessage, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError)
{
if (protocolErrors->length()) {
- reportProtocolError(&callId, InvalidParams, protocolErrors);
+ reportProtocolError(&callId, InvalidParams, errorMessage, protocolErrors);
return;
}
if (invocationError.length()) {
@@ -533,31 +533,31 @@
{
my $reportProtocolError = << "EOF";
-void ${backendClassName}::reportProtocolError(const long* const callId, CommonErrorCode code, const String& customText) const
+void ${backendClassName}::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage) const
{
- RefPtr<InspectorArray> data = ""
- data->pushString(customText);
- reportProtocolError(callId, code, data.release());
+ reportProtocolError(callId, code, errorMessage, 0);
}
-void ${backendClassName}::reportProtocolError(const long* const callId, CommonErrorCode code, PassRefPtr<InspectorArray> data) const
+void ${backendClassName}::reportProtocolError(const long* const callId, CommonErrorCode code, const String& errorMessage, PassRefPtr<InspectorArray> data) const
{
- DEFINE_STATIC_LOCAL(Vector<String>,s_commonErrors,);
+ DEFINE_STATIC_LOCAL(Vector<int>,s_commonErrors,);
if (!s_commonErrors.size()) {
- s_commonErrors.insert(ParseError, "{\\\"code\\\":-32700,\\\"message\\\":\\\"Parse error.\\\"}");
- s_commonErrors.insert(InvalidRequest, "{\\\"code\\\":-32600,\\\"message\\\":\\\"Invalid Request.\\\"}");
- s_commonErrors.insert(MethodNotFound, "{\\\"code\\\":-32601,\\\"message\\\":\\\"Method not found.\\\"}");
- s_commonErrors.insert(InvalidParams, "{\\\"code\\\":-32602,\\\"message\\\":\\\"Invalid params.\\\"}");
- s_commonErrors.insert(InternalError, "{\\\"code\\\":-32603,\\\"message\\\":\\\"Internal error.\\\"}");
- s_commonErrors.insert(ServerError, "{\\\"code\\\":-32000,\\\"message\\\":\\\"Server error.\\\"}");
+ s_commonErrors.insert(ParseError, -32700);
+ s_commonErrors.insert(InvalidRequest, -32600);
+ s_commonErrors.insert(MethodNotFound, -32601);
+ s_commonErrors.insert(InvalidParams, -32602);
+ s_commonErrors.insert(InternalError, -32603);
+ s_commonErrors.insert(ServerError, -32000);
}
ASSERT(code >=0);
ASSERT((unsigned)code < s_commonErrors.size());
ASSERT(s_commonErrors[code]);
- ASSERT(InspectorObject::parseJSON(s_commonErrors[code]));
- RefPtr<InspectorObject> error = InspectorObject::parseJSON(s_commonErrors[code])->asObject();
+ RefPtr<InspectorObject> error = InspectorObject::create();
+ error->setNumber("code", s_commonErrors[code]);
+ error->setString("message", errorMessage);
ASSERT(error);
- error->setArray("data", data);
+ if (data)
+ error->setArray("data", data);
RefPtr<InspectorObject> message = InspectorObject::create();
message->setObject("error", error);
if (callId)
@@ -633,42 +633,42 @@
RefPtr<InspectorValue> parsedMessage = InspectorValue::parseJSON(message);
if (!parsedMessage) {
- reportProtocolError(0, ParseError, "Message should be in JSON format.");
+ reportProtocolError(0, ParseError, "Message should be in JSON format");
return;
}
RefPtr<InspectorObject> messageObject = parsedMessage->asObject();
if (!messageObject) {
- reportProtocolError(0, InvalidRequest, "Invalid message format. The message should be a JSONified object.");
+ reportProtocolError(0, InvalidRequest, "Message should be a JSONified object");
return;
}
RefPtr<InspectorValue> callIdValue = messageObject->get("id");
if (!callIdValue) {
- reportProtocolError(0, InvalidRequest, "Invalid message format. 'id' property was not found in the request.");
+ reportProtocolError(0, InvalidRequest, "'id' property was not found");
return;
}
if (!callIdValue->asNumber(&callId)) {
- reportProtocolError(0, InvalidRequest, "Invalid message format. The type of 'id' property should be number.");
+ reportProtocolError(0, InvalidRequest, "The type of 'id' property should be number");
return;
}
RefPtr<InspectorValue> methodValue = messageObject->get("method");
if (!methodValue) {
- reportProtocolError(&callId, InvalidRequest, "Invalid message format. 'method' property wasn't found.");
+ reportProtocolError(&callId, InvalidRequest, "'method' property wasn't found");
return;
}
String method;
if (!methodValue->asString(&method)) {
- reportProtocolError(&callId, InvalidRequest, "Invalid message format. The type of 'method' property should be string.");
+ reportProtocolError(&callId, InvalidRequest, "The type of 'method' property should be string");
return;
}
HashMap<String, CallHandler>::iterator it = dispatchMap.find(method);
if (it == dispatchMap.end()) {
- reportProtocolError(&callId, MethodNotFound, "Invalid method name was received. '" + method + "' wasn't found.");
+ reportProtocolError(&callId, MethodNotFound, "'" + method + "' wasn't found");
return;
}
@@ -840,9 +840,36 @@
var messageObject = (typeof message === "string") ? JSON.parse(message) : message;
if ("id" in messageObject) { // just a response for some request
- if (messageObject.error && messageObject.error.code !== -32000)
- this.reportProtocolError(messageObject);
+ if (messageObject.error) {
+ messageObject.error.__proto__ = {
+ getDescription: function()
+ {
+ switch(this.code) {
+ case -32700: return "Parse error";
+ case -32600: return "Invalid Request";
+ case -32601: return "Method not found";
+ case -32602: return "Invalid params";
+ case -32603: return "Internal error";;
+ case -32000: return "Server error";
+ }
+ },
+ toString: function()
+ {
+ var description ="Unknown error code";
+ return this.getDescription() + "(" + this.code + "): " + this.message + "." + (this.data ? " " + this.data.join(" ") : "");
+ },
+
+ getMessage: function()
+ {
+ return this.message;
+ }
+ }
+
+ if (messageObject.error.code !== -32000)
+ this.reportProtocolError(messageObject);
+ }
+
var arguments = [];
if (messageObject.result) {
for (var key in messageObject.result)
@@ -1051,8 +1078,8 @@
push(@backendHead, " LastEntry,");
push(@backendHead, " };");
push(@backendHead, "");
- push(@backendHead, " void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorText) const;");
- push(@backendHead, " void reportProtocolError(const long* const callId, CommonErrorCode, PassRefPtr<InspectorArray> data) const;");
+ push(@backendHead, " void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage) const;");
+ push(@backendHead, " void reportProtocolError(const long* const callId, CommonErrorCode, const String& errorMessage, PassRefPtr<InspectorArray> data) const;");
push(@backendHead, " void dispatch(const String& message);");
push(@backendHead, " static bool getCommandName(const String& message, String* result);");
push(@backendHead, "");
@@ -1081,6 +1108,8 @@
unshift(@backendConstantDefinitions, "const char* InspectorBackendDispatcher::commandNames[] = {");
push(@backendConstantDefinitions, "};");
+ push(@backendConstantDefinitions, "");
+ push(@backendConstantDefinitions, "static const char* s_argumentsErrorTemplate = \"Some arguments of method '%s' can't be processed\";");
# Make dispatcher methods private on the backend.
push(@backendConstantDeclarations, "};");
@@ -1095,7 +1124,7 @@
}
}
- push(@backendConstantDeclarations, " void sendResponse(long callId, PassRefPtr<InspectorObject> result, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError);");
+ push(@backendConstantDeclarations, " void sendResponse(long callId, PassRefPtr<InspectorObject> result, const String& errorMessage, PassRefPtr<InspectorArray> protocolErrors, ErrorString invocationError);");
generateBackendAgentFieldsAndConstructor();
_______________________________________________ webkit-changes mailing list [email protected] http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes
