Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Error reporting
Error reporting [message #46210] Wed, 12 September 2007 07:25 Go to next message
Markus Wolf is currently offline Markus WolfFriend
Messages: 153
Registered: July 2009
Senior Member
Hi,

can anyone give me a hint on how to display StackTraces with the
StatusManager correctly?
Here is my code, but this will result in a stacktrace on a single line which
is not very readable...

StringWriter w = new StringWriter();
t.printStackTrace(new PrintWriter(w));

String eMsg = t.getLocalizedMessage();
if (eMsg == null) {
eMsg = "No message given";
}

MultiStatus status = new MultiStatus(pluginId, IStatus.OK, eMsg, t);
status.add(new Status(IStatus.ERROR, pluginId, IStatus.OK,
w.toString(), t));

StatusManager.getManager().handle(status,
StatusManager.BLOCK | StatusManager.LOG);

Markus Wolf
--
> emedia-solutions wolf web: http://www.emedia-solutions-wolf.de
> Eimsbüttler Straße 115 mail: markus@emedia-solutions-wolf.de
> 22769 Hamburg pgp: http://wwwkeys.de.pgp.net
> +49 40 432 635 83 taxid: 57 / 126 / 16123
Re: Error reporting [message #46570 is a reply to message #46210] Wed, 12 September 2007 13:07 Go to previous message
Benjamin Muskalla is currently offline Benjamin MuskallaFriend
Messages: 237
Registered: July 2009
Senior Member
Hi Markus,

the "problem" is that the table widget does not support multi line texts
- neither in SWT nor in RWT.

Also the used ErrorDialog of the workbench does not support showing
stacktraces.
One workaround (for RCP and RAP) is to log each line of your stacktrace
as own IStatus object.

Could be done like this:

MultiStatus status = new MultiStatus("foo.bar", IStatus.OK, eMsg, t);
String trace = w.toString();
String[] traces = trace.split("\r\n");
for (int i = 0; i < traces.length; i++) {
String string = traces[i];
status.add(new Status(IStatus.ERROR, "foo.bar", IStatus.OK,
string , null));
}
StatusManager.getManager().handle(status,
StatusManager.BLOCK | StatusManager.LOG);

Greets
Benny

Markus Wolf wrote:
> Hi,
>
> can anyone give me a hint on how to display StackTraces with the
> StatusManager correctly?
> Here is my code, but this will result in a stacktrace on a single line which
> is not very readable...
>
> StringWriter w = new StringWriter();
> t.printStackTrace(new PrintWriter(w));
>
> String eMsg = t.getLocalizedMessage();
> if (eMsg == null) {
> eMsg = "No message given";
> }
>
> MultiStatus status = new MultiStatus(pluginId, IStatus.OK, eMsg, t);
> status.add(new Status(IStatus.ERROR, pluginId, IStatus.OK,
> w.toString(), t));
>
> StatusManager.getManager().handle(status,
> StatusManager.BLOCK | StatusManager.LOG);
>
> Markus Wolf
Previous Topic:IRunnableWithProgress problem
Next Topic:virtual table
Goto Forum:
  


Current Time: Fri Mar 29 05:12:24 GMT 2024

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

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

Back to the top