Error reporting [message #46210] |
Wed, 12 September 2007 07:25  |
Markus Wolf 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  |
Benjamin Muskalla 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
|
|
|
Powered by
FUDForum. Page generated in 0.01962 seconds