Opened 13 years ago

Closed 12 years ago

#2041 closed enhancement (fixed)

Improve handling of nested exceptions in ContentPane

Reported by: mikewse@… Owned by: mumme
Priority: high Milestone: 0.9
Component: Dijit Version: 0.4.1
Keywords: Cc:
Blocked By: Blocking:

Description

When exceptions occur in event handlers called by ContentPane?, they are summarized in a string (err in code below) that is passed to the applicable error handler (onExecError etc) by calling _handleDefaults (see code below).

It would be very convenient to have the real exception object passed on to the error handlers, instead of the string, as there is often additional information that aids debugging in the exception object (stack trace etc). This information could even be used in a standard error message dialog so end users can report to their helpdesk about the cause of the problem. (But doing this in a safe way may be hard to achieve)

When this is in place it would be possible to have an onExecError handler that can examine the exception object and take the right actions based upon this. It could even be desirable to rethrow the exception object from the onExecHandler to signal outer levels about the error (window.onerror or similar), so the exception should not be consumed by outer levels of ContentPane?.

_runStack: function(stName){
  var st = this[stName]; var err = "";
  var scope = this.scriptScope || window;
  for(var i = 0;i < st.length; i++){
    try{
      st[i].call(scope);
    }catch(e){ 
      err += "
"+st[i]+" failed: "+e.description;
    }
  }
  this[stName] = [];

  if(err.length){
    var name = (stName== "_onLoadStack") ? "addOnLoad" : "addOnUnLoad";
    this._handleDefaults(name+" failure
 "+err, "onExecError", "debug");
  }
},

Best regards Mike Wilson

Change History (3)

comment:1 Changed 13 years ago by bill

Milestone: 0.5
Owner: changed from anonymous to mumme

comment:2 Changed 12 years ago by Adam Peller

Component: GeneralDijit

comment:3 Changed 12 years ago by mumme

Resolution: fixed
Status: newclosed

Well scripts in content and therefore onExecError didn't survive the 0.9 port to dijit.

But onDownloadError and onContentError gets invoked with the error object as the first argument.

Not catching errors in ContentPane? is not very robust, imagine that a error happens on widget creation in a page, if it bubbles up to top level and isn't catched by user code in window.onerror the event loop that creates the widgets is stopped and leaving the user with a halffinished page.

If you want to bubble errors to window.onerror for whatever reason, you can easily do that by re-throwing in onDownloadError and onContentError event handlers.

Note: See TracTickets for help on using tickets.