Opened 14 years ago

Closed 13 years ago

Last modified 12 years ago

#264 closed defect (fixed)

dojo.raise() calls println() even when exception is caught

Reported by: Brian Douglas Skinner <openrecord@…> Owned by: Adam Peller
Priority: high Milestone:
Component: Core Version: 0.2
Keywords: Cc: skinner@…
Blocked By: Blocking:

Description

dojo.raise() always calls dojo.hostenv.println("FATAL"), regardless of whether the exception is caught and squelched.

For example, if you do this, you still get a "FATAL" message:

  try {
    dojo.raise("wanh");
  } catch (e) {
    tryAgian = true; // not fatal, so we squelch
  }

Would it be better to do the println("FATAL") call in some top level error handler? For example, if dojo is running in a browser, it could set window.onerror=dojo.errorHandler(), which should only get called if the exception has not been caught and squelched.

Change History (7)

comment:1 Changed 13 years ago by anonymous

Owner: changed from anonymous to skinner

comment:2 Changed 13 years ago by anonymous

Milestone: 0.3release0.4

comment:3 Changed 13 years ago by Adam Peller

Owner: changed from skinner to Adam Peller

comment:4 Changed 13 years ago by Adam Peller

The proposed solution will not be precise, as a caught exception may still get reported later if an onerror condition occurs; the exception report will be stale. In some ways this is an improvement over reporting the exception always when it is caught, though the timing will be off, further complicating debugging.

The only other solution I can think of, besides WONTFIX, is to change the println to indicate "FATAL exception raised" so it's not as misleading.

comment:5 Changed 13 years ago by skinner

Cc: skinner@… added; Brian Douglas Skinner <openrecord@…> removed

What about having some config variable that allows somebody to optionally turn off that println("FATAL")?

djConfig.verboseExceptions = false;

That would make it possible to squelch bogus FATAL messages in some scenarios, while still not messing up people who rely on the println("FATAL") being there.

Or, maybe another option is to just use the existing djConfig.isDebug...

dojo.raise = function(/*String*/ message, /*Error?*/ exception){
	if(exception){
		message = message + ": "+dojo.errorToString(exception);
	}
	if (djConfig.isDebug) {
		try {	dojo.hostenv.println("FATAL: "+message); } catch (e) {}
	}

	throw Error(message);
}

comment:6 Changed 13 years ago by Adam Peller

Resolution: fixed
Status: newclosed

(In [5779]) Change dojo.raise() to rethrow exception, only print FATAL "exception raised" message for isDebug. Fixes #264 and #1410

comment:7 Changed 12 years ago by (none)

Milestone: 0.4

Milestone 0.4 deleted

Note: See TracTickets for help on using tickets.