Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Why ErrorDialog is not showing exception's stack trace from IStatus?
Why ErrorDialog is not showing exception's stack trace from IStatus? [message #802433] Mon, 20 February 2012 00:26 Go to next message
Libor Jelinek is currently offline Libor JelinekFriend
Messages: 143
Registered: January 2012
Location: Prague, Czech Rep.
Senior Member

Hello everbody!
Consider this example:

try {
  LoginService.authenticate(sysinfo, user);

} catch (LoggingException e) {

  Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,  e.getLocalizedMessage(), e);

  ErrorDialog.openError(getShell(), "Error", "Exception occured during authentication!", status);
}


Why JFace ErrorDialog is not showing full stack trace (same like e.printStackTrace()) after pressing "Details >>" button? Actually it is showing just e.getLocalizedMessage() (i.e. just name of exception):

index.php/fa/7220/0/

That's useless. It should contain similar output like e.printStackTrace() to be helpful:

com.virtage.plexflow.system.LoggingException: Authentication failed due to exception
	at com.virtage.plexflow.system.LoginService.authenticate(LoginService.java:44)
	at com.virtage.plexflow.system.LoginDialog.handleOk(LoginDialog.java:333)
	at com.virtage.plexflow.system.LoginDialog.buttonPressed(LoginDialog.java:252)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3588)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3209)
Caused by: java.lang.RuntimeException: Failed to build SqlSessionFactory due to exception
	at com.virtage.plexflow.db.PxSqlSessionFactory.<init>(PxSqlSessionFactory.java:76)
	at com.virtage.plexflow.system.SystemInfo.getSqlSessionFactory(SystemInfo.java:84)
	at com.virtage.plexflow.system.LoginService.authenticate(LoginService.java:42)
	... 25 more



Thanks for any ideas!

[Updated on: Mon, 20 February 2012 00:29]

Report message to a moderator

Re: Why ErrorDialog is not showing exception's stack trace from IStatus? [message #810258 is a reply to message #802433] Wed, 29 February 2012 22:38 Go to previous messageGo to next message
Patrik Dufresne is currently offline Patrik DufresneFriend
Messages: 10
Registered: July 2009
Junior Member
Agreed with you. To overcome this problem, I change the Policy to use a custom implementation of the ErrorDialog displaying the stack trace.
Re: Why ErrorDialog is not showing exception's stack trace from IStatus? [message #810599 is a reply to message #810258] Thu, 01 March 2012 10:03 Go to previous messageGo to next message
Libor Jelinek is currently offline Libor JelinekFriend
Messages: 143
Registered: January 2012
Location: Prague, Czech Rep.
Senior Member

What do you mean with "Policy", please?

Finally, I also found workaround with converting lines produced by printStackTrace() to MultiStatus.

Unfortunately I can't share a link in this topic here because I don't have enough "credit" (some kind of anti-spam policy). To overcome it please replace spaces with slashes.

http : / / stackoverflow . com / questions / 2826959 / jface-errordialog-how-do-i-show-something-in-the-details-portion /9404081#9404081

(I hope that I will not be banned because of this Smile).
Re: Why ErrorDialog is not showing exception's stack trace from IStatus? [message #810700 is a reply to message #810599] Thu, 01 March 2012 12:56 Go to previous messageGo to next message
Patrik Dufresne is currently offline Patrik DufresneFriend
Messages: 10
Registered: July 2009
Junior Member
Libor JelĂ­nek wrote on Thu, 01 March 2012 05:03
What do you mean with "Policy", please?


By Policy, I'm referring to the JFace Policy utility class (org.eclipse.jface.util.Policy). This class isued by JFace to handle un expected exception. You may call Policy.setStatusHandler(StatusHandler status) to replace the default handler.

In my project, I change the default StatusHandler to use my implementation of SafeRunnableDialog.
Re: Why ErrorDialog is not showing exception's stack trace from IStatus? [message #810769 is a reply to message #810700] Thu, 01 March 2012 14:36 Go to previous messageGo to next message
Libor Jelinek is currently offline Libor JelinekFriend
Messages: 143
Registered: January 2012
Location: Prague, Czech Rep.
Senior Member

Sorry but I am confused what are differences among these means:
* JFace Policy object
* org.eclipse.ui.statusHandlers extention point
* WorkbenchAdvistor.eventLoopException() method

AFAIK they are very similar.

What is the highest (the most top) place to catch exceptions?

What is recommended place catch exception and show them as nicely polished dialog to the users?

Thanks
Libor
Re: Why ErrorDialog is not showing exception's stack trace from IStatus? [message #810975 is a reply to message #810769] Thu, 01 March 2012 19:10 Go to previous message
Patrik Dufresne is currently offline Patrik DufresneFriend
Messages: 10
Registered: July 2009
Junior Member
Indeed they are very similar. The big difference between each of them is their usage. Jface librairies (Viewers, and other) will use JFace Policy. WorkbenchAdvistor will be use by workbench specific class. For statusHandlers, I don't know what it is.
Previous Topic:Binding text on button
Next Topic:ComboBoxViewerCellEditor problem
Goto Forum:
  


Current Time: Fri Dec 19 20:19:23 GMT 2014

Powered by FUDForum. Page generated in 0.14359 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software