RESOLVED FIXED161187
[GTK] Provide details on javascript exception
https://bugs.webkit.org/show_bug.cgi?id=161187
Summary [GTK] Provide details on javascript exception
David Keijser
Reported 2016-08-25 01:10:43 PDT
Running `webkit_web_view_run_javascript` with a script that fails the error object returned contains no information on what went wrong but only the message "An exception was raised in JavaScript". Having access to at least the javascript error message would help debugging a lot.
Attachments
Patch (3.87 KB, patch)
2017-05-22 12:07 PDT, David Keijser
no flags
Patch (4.54 KB, patch)
2017-05-23 02:49 PDT, David Keijser
no flags
Patch (4.52 KB, patch)
2017-05-24 00:28 PDT, David Keijser
no flags
David Keijser
Comment 1 2017-05-22 12:07:31 PDT
Build Bot
Comment 2 2017-05-22 12:10:36 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Michael Catanzaro
Comment 3 2017-05-22 16:26:59 PDT
Comment on attachment 310896 [details] Patch Wow nice, thanks! This looks perfect to me. I'll let this sit a day to give someone else a chance to review it too; please complain here if nobody else responds soon. Also, you probably want to set the cq? flag to request commit.
Carlos Garcia Campos
Comment 4 2017-05-22 23:11:06 PDT
Comment on attachment 310896 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=310896&action=review Thanks for the patch. > Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp:3139 > - _("An exception was raised in JavaScript")); > + _("An exception was raised in JavaScript: %s"), exceptionDetails.message.utf8().data()); Now that we have the error details, I think the prefix "An exception was raised in JavaScript" is kind of redundant, we know that from the error code WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED. I think we can use all the details to build a complete error message, consistent with messages shown by the inspector or stdout when setting enable-write-console-messages-to-stdout is enabled. If we have a url, then we add url with line and column, and then error message, if we don't have a url we just show the error message. You can see how the message is built in Source/JavaScriptCore/runtime/ConsoleClient.cpp
David Keijser
Comment 5 2017-05-23 02:49:03 PDT
David Keijser
Comment 6 2017-05-23 02:55:46 PDT
Thanks for the review, I have updated the patch. However I've noted that the sourceURL is always "undefined", line numbers works though. I'm not sure how to get that field properly populated.
Carlos Garcia Campos
Comment 7 2017-05-23 03:43:09 PDT
(In reply to David Keijser from comment #6) > Thanks for the review, I have updated the patch. > > However I've noted that the sourceURL is always "undefined", line numbers > works though. I'm not sure how to get that field properly populated. You mean it's empty or that it's the string "undefined"? It sounds like a bug, then.
Carlos Garcia Campos
Comment 8 2017-05-23 03:44:29 PDT
Comment on attachment 310990 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=310990&action=review > Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp:3152 > + builder.append(exceptionDetails.message.utf8().data()); Do not convert to utf8 here builder.append(exceptionDetails.message);
David Keijser
Comment 9 2017-05-23 03:49:01 PDT
it's always set and always the string "undefined", sry for the confusion :)
David Keijser
Comment 10 2017-05-24 00:28:11 PDT
Carlos Garcia Campos
Comment 11 2017-05-24 10:10:10 PDT
Comment on attachment 311106 [details] Patch We need to investigate why source URL is "undefined", but that's a different bug in any case. Could you file a new bug report or that, please?
Michael Catanzaro
Comment 12 2017-05-24 13:00:44 PDT
(In reply to Michael Catanzaro from comment #3) > Also, you probably want to set the cq? flag to request commit.
WebKit Commit Bot
Comment 13 2017-05-24 15:00:01 PDT
Comment on attachment 311106 [details] Patch Clearing flags on attachment: 311106 Committed r217389: <http://trac.webkit.org/changeset/217389>
WebKit Commit Bot
Comment 14 2017-05-24 15:00:03 PDT
All reviewed patches have been landed. Closing bug.
David Keijser
Comment 15 2017-05-25 03:59:16 PDT
Note You need to log in before you can comment on or make changes to this bug.