Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » How to track down an error thrown in the javascript code?
How to track down an error thrown in the javascript code? [message #1800141] Thu, 20 December 2018 11:45 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 572
Registered: October 2012
Location: Bern, Switzerland
Senior Member

We have deployed a Scout application using Scout version 6.1.0.xxxxx (yes, I know that is fairly old).

We've come across a situation where there seems to be an issue somewhere in the javascript code, but we haven't figured out how to track down what causes this issue.

Our log output looks as follows:

2018-12-19 14:09:33,988] [http-bio-9480-exec-10] ERROR org.eclipse.scout.rt.ui.html.json.JsonMessageRequestHandler handleLogRequest -   JavaScript exception occured
Unable to get property 'detach' of undefined or null reference at https://localhost:9480/angebot/res/angebot-all.js:73191
TypeError: Unable to get property 'detach' of undefined or null reference
   at Anonymous function (https://localhost:9480/angebot/res/angebot-all.js:73191:34)
(Code T6)
[2018-12-19 14:09:37,299] [http-bio-9480-exec-3] DEBUG ch.sbb.cisi.core.scout.ui.html.CisiAccessController handle -   handling path = /json, requestURI = /angebot/json, context = /angebot

Looking at the referenced Java class I found this method:
  protected void handleLogRequest(HttpServletResponse resp, IUiSession uiSession, JsonRequest jsonRequest) throws IOException {
    String message = jsonRequest.getMessage();
    JSONObject event = jsonRequest.getEvent();

    String header = "JavaScript exception occured";
    if (event != null) {
      String target = event.getString("target");
      String type = event.getString("type");
      header += " while processing event " + type + " for adapter " + uiSession.getJsonAdapter(target);
    message = header + "\n" + message;
    if (message.length() > 10000) {
      // Truncate the message to prevent log inflation by malicious log requests
      message = message.substring(0, 10000) + "...";
    writeJsonResponse(resp, m_jsonRequestHelper.createEmptyResponse());

Sadly, that does not really help me to locate the code that causes this issue. Is there an easy way to get back from the compiled & minified angebot-all.js line reference to the original javascript code?

What does "Code T6" stand for? As far as we know, these codes usually consist of the first letter of the exception that is thrown plus the length of its name, but we're not aware of any 6-letter exceptions starting with T...

  • Attachment: CodeT6.png
    (Size: 24.54KB, Downloaded 105 times)
Re: How to track down an error thrown in the javascript code? [message #1800144 is a reply to message #1800141] Thu, 20 December 2018 12:45 Go to previous message
Beat Schwarzentrub is currently offline Beat SchwarzentrubFriend
Messages: 114
Registered: November 2010
Senior Member

By default, uncaught JavaScript errors are only logged to the browsers developer console. Scout catches all errors and does two things:
1. It tries to report the error to the server, where it is simply output to the log file. This can help during error analysis (otherwise the error would only be accessible on the client side).
2. It shows a message box with the "unexpected problem" message. This is done to inform the user that something has gone wrong and more strange things are about to happen when the error is just ignored.

In development mode, your JavaScript file should not be minified. You can access the compiled file and the exact location via the browsers development tools. In most browsers, they can be opened by pressing F12. To debug JavaScript, we recommend Google Chrome or Firefox, as they offer the fastest and most versatile developer tools. Internet Explorer/Edge tools are quite bad.

In your case, you can easily make a breakpoint at the indicated location and inspect the call stack. "detach" indicates some error while hiding an element. If the error happens in a custom widget, you have most likely called something in the wrong method (e.g. access a DOM element outside a _render... method). If only normal scout widgets are involved, it could be a bug. Your best changes to get it fixed is providing a minimal example that can reproduce the error.

The code T6 indicates the type of JavaScript error, but has no significance otherwise. See ErrorHandler.js

Previous Topic:Upgrade to 8.0 issues : TEXTS, version
Next Topic:Empty ClientPreferences in ClientSession.execLoadSession after logout and re-login
Goto Forum:

Current Time: Mon Feb 17 10:14:08 GMT 2020

Powered by FUDForum. Page generated in 0.01796 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top