[ 
https://issues.apache.org/jira/browse/PIVOT-916?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13782048#comment-13782048
 ] 

Roger Whitcomb commented on PIVOT-916:
--------------------------------------

Another thought that (I don't think) would require any user application change 
is to add logic to "handleUncaughtException" in ApplicationContext to put up an 
Alert in addition to "exception.printStackTrace()" if there are no handlers 
registered.  It could check if there are any active Display objects (using 
"displays.getLength() != 0") and then use the primary display to show an Alert. 
 Basically this would mean moving the code that is currently in 
Application.Adapter in "displayException" down into 
ApplicationContext.handleUncaughtException.  

The other problem I see is that DesktopApplicationContext puts the application 
into the "applications" list BEFORE calling "startup", while 
BrowserApplicationContext puts the application into the list AFTER successfully 
calling "startup".  Maybe this is the source of the problem to begin with 
(i.e., that startup exceptions never make it to the Application's 
"UncaughtExceptionHandler" because the application isn't in the list.... (or at 
least part of the problem).

So, doing both these changes I think this would still allow applications to 
override the default handling of uncaught exceptions (which would be to both 
print the stack trace to the console, and show an Alert if there was any 
Display active), and have startup exceptions caught and handled by whatever 
mechanism is in place.

What do you think?

> Replace DesktopApplicationContext.displayException calls with 
> ApplicationContext.handleUncaughtException
> --------------------------------------------------------------------------------------------------------
>
>                 Key: PIVOT-916
>                 URL: https://issues.apache.org/jira/browse/PIVOT-916
>             Project: Pivot
>          Issue Type: Improvement
>            Reporter: Karel Hübl
>            Assignee: Sandro Martini
>             Fix For: 2.0.4
>
>         Attachments: ScriptApplication.java.patch, trunk_wtk.patch, 
> wtk_test.zip
>
>
> There should be consistent way to handle uncaught exceptions in Pivot 
> applications. 
> However uncaught exceptions thrown in DesktopApplicationContext  class (for 
> example in application.startup ) are handled using private static method 
> displayException, which displays dialog and its logic cannot be overriden.
> May be ApplicationContext.handleUncaughtException could be made protected and 
> calls to DesktopApplicationContext.displayException could be replaced by  
> ApplicationContext.handleUncaughtException. And possibly Application.Adapter 
> could implement UncaughtExceptionHandler - so current 
> DesktopApplicationContext.displayException logic could be moved to new 
> Application.Adapter.uncaughtExceptionThrown method.
> This should enable to override uncaught exception handling globally in pivot 
> applications.
> Motivation:
> We deploy Pivot app using Java Web Start. Users have by default disabled Java 
> Console (and they are not familiar with it). We want to display custom dialog 
> to handle uncaught exceptions displaying full stack trace and with possiblity 
> to report exception to help desk.
> I think, in current implementation it is not possible to override handling of 
> uncaught exceptions thrown during application init and other specific 
> situations.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to