Thanks for the reply, which helped me. I actually updated to Qooxdoo-1.2. However I still face 2 serious problems:
1) The stacktrace is empty as Alexander also pointed out, and there is no way to obtain a stacktrace apparently. 2) (This is very serious for us) On the playground, your code worked but on our own application it did not work. I tried to understand why and after a *long* session of debugging I finally got it: the page hosting the application is on a different domain than the server hosting the Qooxdoo JS files. This has the unfortunate effect that the exception that I get from a simple a= b; when b is not defined, is not the good one; it's always a "ScriptError". Do you have any insight on that so that I can fix this problem? Our application MUST run on different domains that the server hosting the Qooxdoo code... Jean-Noel On Tue, Sep 21, 2010 at 3:03 PM, Tino Butz <[email protected]> wrote: > Hi Jean-Noël, > > To add a global error handling to your application, I would suggest that you > create an ErrorHandler Class that does all the error handling and sends the > error reports to your server. The instance of the class > > would register an error handler to the qx.event.GlobalError: > > qx.event.GlobalError.setErrorHandler(this.__globalErrorHandler, this); > > The error handler would do something like this: > > __globalErrorHandler : function(exc) { > qx.log.Logger.error(this, exc.getSourceException()); // I guess the > exception is not wrapped in 1.0 - the exc would be the system exception > // or you can use this > // qx.log.Logger.error(this, > qx.dev.StackTrace.getStackTraceFromError(exc.getSourceException())); > var events = ringBuffer.getAllLogEvents(); > var jsonLog = qx.util.Json.stringify(events); > ringBuffer.clearHistory(); > // Send the error to a server instead of the console log > console.log(jsonLog); > } > > I suggest you use a ringBuffer for the Logger, to save memory usage when the > application is running for a long time. > > > > > Here is the playground code: > > > > > // Create a button > var button1 = new qx.ui.form.Button("Give me an error", > "icon/22/apps/internet-web-browser.png"); > > // Document is the application root > var doc = this.getRoot(); > > // Add button to document at fixed coordinates > doc.add(button1, > { > left : 100, > top : 50 > }); > > > var ringBuffer = new qx.log.appender.RingBuffer(); > qx.log.Logger.register(ringBuffer); > > > button1.addListener("execute", function(e) { > throw new Error("I am an evil error"); > }, this); > > > var globalErrorHandler = function(exc) { > qx.log.Logger.error(this, exc.getSourceException()); > // or you can use this > // qx.log.Logger.error(this, > qx.dev.StackTrace.getStackTraceFromError(exc.getSourceException())); > var events = ringBuffer.getAllLogEvents(); > var jsonLog = qx.util.Json.stringify(events); > ringBuffer.clearHistory(); > // Send the error to a server instead of the console log > console.log(jsonLog); > }; > > qx.event.GlobalError.setErrorHandler(globalErrorHandler, this); > > // Alternative to add error handling > > /* > var handleExecute = qx.event.GlobalError.observeMethod(function(e) { > throw new Error("I am an evil error"); > }); > */ > > /* > var handleExecute = function(e) { > throw new Error("I am an evil error"); > }; > */ > > // Add an event listener > /* > button1.addListener("execute", handleExecute, this); > */ > > Here is the link to the playground: > > http://demo.qooxdoo.org/devel/playground/#%7B%22code%22%3A%20%22%252F%252F%2520Create%2520a%2520button%250Avar%2520button1%2520%253D%2520new%2520qx.ui.form.Button%28%2522Give%2520me%2520an%2520error%2522%252C%2520%2522icon%252F22%252Fapps%252Finternet-web-browser.png%2522%29%253B%250A%250A%252F%252F%2520Document%2520is%2520the%2520application%2520root%250Avar%2520doc%2520%253D%2520this.getRoot%28%29%253B%250A%250A%252F%252F%2520Add%2520button%2520to%2520document%2520at%2520fixed%2520coordinates%250Adoc.add%28button1%252C%250A%257B%250A%2520%2520left%2520%253A%2520100%252C%250A%2520%2520top%2520%2520%253A%252050%250A%257D%29%253B%250A%250A%250Avar%2520ringBuffer%2520%253D%2520new%2520qx.log.appender.RingBuffer%28%29%253B%250Aqx.log.Logger.register%28ringBuffer%29%253B%250A%250A%250Abutton1.addListener%28%2522execute%2522%252C%2520function%28e%29%2520%257B%250A%2520%2520throw%2520new%2520Error%28%2522I%2520am%2520an%2520evil%2520error%2522%29%253B%250A%257D%252C%2520this%29%253B%250A%250A%250Avar%2520globalErrorHandler%2520%253D%2520function%28exc%29%2520%257B%250A%2520%2520qx.log.Logger.error%28this%252C%2520exc.getSourceException%28%29%29%253B%250A%2520%2520%252F%252F%2520or%2520you%2520can%2520use%2520this%250A%2520%2520%252F%252Fqx.log.Logger.error%28this%252C%2520qx.dev.StackTrace.getStackTraceFromError%28exc.getSourceException%28%29%29%29%253B%250A%2520%2520var%2520events%2520%253D%2520ringBuffer.getAllLogEvents%28%29%253B%250A%2520%2520var%2520jsonLog%2520%253D%2520qx.util.Json.stringify%28events%29%253B%250A%2520%2520ringBuffer.clearHistory%28%29%253B%250A%2520%2520%252F%252F%2520Send%2520the%2520error%2520to%2520a%2520server%2520instead%2520of%2520the%2520console%2520log%250A%2520%2520console.log%28jsonLog%29%253B%250A%257D%253B%250A%250Aqx.event.GlobalError.setErrorHandler%28globalErrorHandler%252C%2520this%29%253B%250A%250A%250A%250A%252F%252F%2520Alternative%2520to%2520add%2520error%2520handling%250A%250A%250A%252F*%250Avar%2520handleExecute%2520%253D%2520qx.event.GlobalError.observeMethod%28function%28e%29%2520%257B%250A%2520%2520throw%2520new%2520Error%28%2522I%2520am%2520an%2520evil%2520error%2522%29%253B%250A%257D%29%253B%250A*%252F%250A%250A%252F*%250Avar%2520handleExecute%2520%253D%2520function%28e%29%2520%257B%250A%2520%2520throw%2520new%2520Error%28%2522I%2520am%2520an%2520evil%2520error%2522%29%253B%250A%257D%253B%250A*%252F%250A%250A%252F%252F%2520Add%2520an%2520event%2520listener%250A%252F*%250Abutton1.addListener%28%2522execute%2522%252C%2520handleExecute%252C%2520this%29%253B%250A*%252F%250A%22%7D > > > > ----- Original Message ----- > > From: Jean-Noël Rivasseau > > Sent: 20/09/10 04:00 PM > > To: qooxdoo Development > > Subject: [qooxdoo-devel] Using a global error handler in Qx > > Hello, We are at the point where we need to have extensive JS error logging > in production for our web-app. I've seen that Qx already tackles this > problem with a qx.event.GlobalError class. However I played with it this > morning (we're still under 1.0 but could update to 1.2.x if improvements > have been made in this area), and I was not really able to do anything > useful with it. The two points that bother me: 1) Is there an entry point > for qx.io.remote.transport.Script._requestFinished() ? It would seem normal > to have one, else every exception occuring on the return of a server request > won't be handled. But from my tests, it seems there isn't. Should I manually > add it ? (seems a bit strange) 2) Once I get the exception in the error > handler, I was not able to do anything with it. I just wrote a very stupid a > =b line on the source (where b is not defined). If I don't have an error > handler defined, under FF this pops up in the Firebug console with useful > information and the line of the error. If I activate the error handler, I > get a qx.core.WindowError object, but it does not contain any useful info: > toString() returns "", getLineNumber() returns 0 .... A global error > handler is definitely something that is needed in a complex web-app and we > really need to use it... but at this point I need help understanding how to > make it work reasonably well. Jean-Noel PS: I read the Qx docs on this. > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances and start using > them to simplify application deployment and accelerate your shift to cloud > computing. http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ qooxdoo-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel > > ------------------------------------------------------------------------------ > Start uncovering the many advantages of virtual appliances > and start using them to simplify application deployment and > accelerate your shift to cloud computing. > http://p.sf.net/sfu/novell-sfdev2dev > _______________________________________________ > qooxdoo-devel mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel > > -- Jean-Noël Rivasseau Directeur (1) 778 786 3460 / (33) 01 82 88 05 26 Kameleoon - morphing the web http://www.kameleoon.com/ ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ qooxdoo-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
