Bug 161187 - [GTK] Provide details on javascript exception
Summary: [GTK] Provide details on javascript exception
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: Other
Hardware: Unspecified Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-25 01:10 PDT by David Keijser
Modified: 2017-05-30 20:22 PDT (History)
8 users (show)

See Also:


Attachments
Patch (3.87 KB, patch)
2017-05-22 12:07 PDT, David Keijser
no flags Details | Formatted Diff | Diff
Patch (4.54 KB, patch)
2017-05-23 02:49 PDT, David Keijser
no flags Details | Formatted Diff | Diff
Patch (4.52 KB, patch)
2017-05-24 00:28 PDT, David Keijser
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Keijser 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.
Comment 1 David Keijser 2017-05-22 12:07:31 PDT
Created attachment 310896 [details]
Patch
Comment 2 Build Bot 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
Comment 3 Michael Catanzaro 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.
Comment 4 Carlos Garcia Campos 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
Comment 5 David Keijser 2017-05-23 02:49:03 PDT
Created attachment 310990 [details]
Patch
Comment 6 David Keijser 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.
Comment 7 Carlos Garcia Campos 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.
Comment 8 Carlos Garcia Campos 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);
Comment 9 David Keijser 2017-05-23 03:49:01 PDT
it's always set and always the string "undefined", sry for the confusion :)
Comment 10 David Keijser 2017-05-24 00:28:11 PDT
Created attachment 311106 [details]
Patch
Comment 11 Carlos Garcia Campos 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?
Comment 12 Michael Catanzaro 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.
Comment 13 WebKit Commit Bot 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>
Comment 14 WebKit Commit Bot 2017-05-24 15:00:03 PDT
All reviewed patches have been landed.  Closing bug.
Comment 15 David Keijser 2017-05-25 03:59:16 PDT
I've created the issue https://bugs.webkit.org/show_bug.cgi?id=172587