0

How can I find what is the script error? ChromeDevTools - Console:

ChromeDevTools - Console

When I clicked in userCodePanel and pre format showed the below source:

<!doctype html>
    <style nonce="dqs2Iw0xA4xt/uhPgBmJpw">
        html, body, iframe {
            border: 0;
            display: block;
            height: 100%;
            margin: 0;
            padding: 0;
            width: 100%;
    }

    iframe#userHtmlFrame {
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
    }
</style>
<meta name="chromevox" content-script="no">
<script type="text/javascript" src="/static/macros/client/js/**code**-mae_html_user_bin_i18n_mae_html_user__pt_br.js" nonce="**code**/**code**"></script>
<script nonce="**code**/**code**">
maeInit_(true);

For security reasons I changed the code number by code.

Stackdriver Logging e Error Report shows no error.

Please with the above informations how can I search for the error?

Rubén
  • 34,714
  • 9
  • 70
  • 166
jcom
  • 91
  • 1
  • 9
  • 1
    By properly error handling the server-side script - at least start with adding a `withFailureHandler` to the client-side code. Also: please, change the userCodePanel source with actual client-side code. Judging from idle -> busy -> idle log, I bet you use `google.script.run` to run a server-side function. – Oleg Valter is with Ukraine Jul 06 '20 at 00:49
  • 1
    Please add a brief description of your search/research efforts as is suggested in [ask]. – Rubén Jul 06 '20 at 01:03
  • @Cooper - not sure if clasp is even relevant here - from my experience the "Error running script" happens in certain cases of unhandled server-side exceptions (hard to tell why it is not logged, though) which is solved by adding a failure handler and / or wrapping the offending code in a normal `try...catch` - the actual error propagates correctly both to the handler and to `catch` – Oleg Valter is with Ukraine Jul 06 '20 at 01:54
  • how are you logging the errors on apps script? – Kessy Jul 06 '20 at 14:13
  • Possible duplicate: https://stackoverflow.com/q/51757573/1595451 (I answered but the answer hasn't votes yet) – Rubén Oct 15 '22 at 03:00

1 Answers1

0

Chrome Dev Tools doesn't know where to take you because the JavaScript code is added dynamically.

One option is to map the client side code to Source Code. Applying this to Google Apps Script web applications is a bit hacky but I have been using it in the last few days and it's working very well.

The goal is to add //# sourceURL=filename.js (use whatever filename you want) before every closing <script> but as JavaScript comments are stripped out by HtmlService we have to use HtmlService.HtmlOutput.append two times, one to add the top html content dow to the first / of the referrend comment, the second to add /# sourceURL=filename.js, the closing <script> and the code after it.

The way to apply the above depends on how your script is creating the HtmlService.HtmlOutput object. Few days ago I posted here a self-answered question including a "mcve" --> How to map client-side code to Source Code

Besides the benefit of being able to see the JavaScript code as Source Code in Chrome dev tools, when the console shows logs and errors related to this code, instead of userCodeAppPanel we will see filename.js (or whatever name you used). Clicking the file name will take to the the corresponding line code in Source Code.

The following screenshot shows how a error message is show in the Chrome Dev Tools, in this case showing navagacion.js (sic) instead of userCodeAppPanel.

References

Rubén
  • 34,714
  • 9
  • 70
  • 166