You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Christopher Brind <br...@brindy.org.uk> on 2009/02/28 11:30:51 UTC

Global/Uncaught Errors/Exceptions

Hi,

Having been watching this Flex bug for some time, I was wondering how Pivot
deals with this?
http://bugs.adobe.com/jira/browse/FP-444

i.e. is there a global exception handler?

Seems like a show stopper for some Flex users and Sliverlight has a global
OnError handler, so I feel it is something Pivot should either support
explicitly, or document how users can handle global/uncaught
errors/exceptions.

I guess at the moment, the exception log would just appear in the applet's
console via STDOUT/STDERR?  Is that enough?

Cheers,
Chris

Re: Global/Uncaught Errors/Exceptions

Posted by Greg Brown <gk...@mac.com>.
> The problem is that application developers could still create their  
> own
> Threads and ThreadGroups, right?  That is, I presume Pivot doesn't  
> prevent
> that.


Correct - in fact, it is encouraged. Pivot provides a Task class that  
is used to simplify execution of background tasks, which run on  
separate threads.

> There's an uncaught exception handler property on Thread:
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)

This may actually be the best solution. Instead of providing a  
platform hook into the event loop, callers can simply attach an  
uncaught exception handler to the UI (event dispatch) thread.

G


Re: Global/Uncaught Errors/Exceptions

Posted by Christopher Brind <br...@brindy.org.uk>.
The problem is that application developers could still create their own
Threads and ThreadGroups, right?  That is, I presume Pivot doesn't prevent
that.  So wrapping application calls in a try/catch block wouldn't help that
scenario.  That said, if application developers are going to do that, then
they should be aware of the Exception handling mechanisms available to them
(see below).  Thus, wrapping the app calls as you suggest and allowing the
developer to specify a global handler sounds like a good idea.

There's an uncaught exception handler property on Thread:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)

You can also subclass ThreadGroup and override the uncaughtException method:
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ThreadGroup.html#uncaughtException(java.lang.Thread,%20java.lang.Throwable)

This seems to be the extent of it from browsing the Java 5 API.

Cheers,
Chris


2009/2/28 Greg Brown <gk...@mac.com>

> There isn't currently a global exception handler. However, pretty much
> everything in a Pivot app happens in response to an event being fired
>  (mouse move, key press, etc.) . The application context is responsible for
> passing these events on to the application and could potentially wrap the
> application calls in a try/catch block. It could further allow the
> application developer to register a global exception handler that would be
> called in the case of an exception being thrown.
>

> However, I have to wonder if the JVM or Java Plugin already has a mechanism
> for handling this. Anyone else know?
>

> Greg
>
>
> On Feb 28, 2009, at 5:30 AM, Christopher Brind wrote:
>
>  Hi,
>>
>> Having been watching this Flex bug for some time, I was wondering how
>> Pivot
>> deals with this?
>> http://bugs.adobe.com/jira/browse/FP-444
>>
>> i.e. is there a global exception handler?
>>
>> Seems like a show stopper for some Flex users and Sliverlight has a global
>> OnError handler, so I feel it is something Pivot should either support
>> explicitly, or document how users can handle global/uncaught
>> errors/exceptions.
>>
>> I guess at the moment, the exception log would just appear in the applet's
>> console via STDOUT/STDERR?  Is that enough?
>>
>> Cheers,
>> Chris
>>
>
>

Re: Global/Uncaught Errors/Exceptions

Posted by Greg Brown <gk...@mac.com>.
There isn't currently a global exception handler. However, pretty much  
everything in a Pivot app happens in response to an event being fired   
(mouse move, key press, etc.) . The application context is responsible  
for passing these events on to the application and could potentially  
wrap the application calls in a try/catch block. It could further  
allow the application developer to register a global exception handler  
that would be called in the case of an exception being thrown.

However, I have to wonder if the JVM or Java Plugin already has a  
mechanism for handling this. Anyone else know?

Greg

On Feb 28, 2009, at 5:30 AM, Christopher Brind wrote:

> Hi,
>
> Having been watching this Flex bug for some time, I was wondering  
> how Pivot
> deals with this?
> http://bugs.adobe.com/jira/browse/FP-444
>
> i.e. is there a global exception handler?
>
> Seems like a show stopper for some Flex users and Sliverlight has a  
> global
> OnError handler, so I feel it is something Pivot should either support
> explicitly, or document how users can handle global/uncaught
> errors/exceptions.
>
> I guess at the moment, the exception log would just appear in the  
> applet's
> console via STDOUT/STDERR?  Is that enough?
>
> Cheers,
> Chris