As I see qx.dev.StackTrace.getStackTraceFromError(exc.getSourceException())
returns empty stack. Also it's not posible to get correct stack trace using
any methods here. Any suggestions?


2010/9/21 Tino Butz <[email protected]>

> 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:
>
>
> var ringBuffer = new qx.log.appender.RingBuffer();
> qx.log.Logger.register(ringBuffer);
>
>
> For event handler that are called directly by the browser you should wrap
> the function using:
>
>
> var eventHandler = qx.event.GlobalError.observeMethod(function(e) {
>   // some code here
> });
>
>
>
> Best regards,
>
> Tino
>
>
>
>   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
>
>


-- 
когда я опустился на самое дно, снизу мне постучали..
------------------------------------------------------------------------------
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

Reply via email to