Is it possible to get a Stack Trace in the code?

I am using Exception.printStackTrace during development on the emulator, but I would like to get it as a string in the code.

I have error reporting feature in my Midlet so it sends info about cought exceptions to the server. Stack Trace would be wonderful, but it is only possible to write it to the standard output.

Any way to redirect it to the string?

Greetings,

Aleksandar Momcilovic

Oslo, Norway

[438 byte] By [amomcila] at [2007-11-26 17:47:42]
# 1
No, none what so ever... I never understood why they forgot the implement the printStackTrace(Writer w) method in j2me...
deepspacea at 2007-7-9 5:00:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2
why don't you use Alert in try / catch?
suparenoa at 2007-7-9 5:00:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3
get the String as Exception.getMessage () then append it to your form.
MelGohana at 2007-7-9 5:00:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
> get the String as Exception.getMessage () then append> it to your form.No, getMessage() will not give you a stack trace, only a stupid message.
deepspacea at 2007-7-9 5:00:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5
Thanks guys, I managed to get more info about this silly omission with the same result - Not possible.So, no way to send Stack Trace back to home, that is very sad news.
amomcila at 2007-7-9 5:00:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6
> Thanks guys, I managed to get more info about this> silly omission with the same result - Not possible.> So, no way to send Stack Trace back to home, that is> very sad news.did you really try Alert objects?
suparenoa at 2007-7-9 5:00:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7
What does an Alert have in common with the stack trace of an exception? There are even J2ME devices with no screen at all, e.g. in the IM profile (as in my case at the moment) and still there's a need to process the stack trace somehow. Unfortunately, it seems to be not possible at all.
Karcia at 2007-7-9 5:00:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 8

> What does an Alert have in common with the stack

> trace of an exception? There are even J2ME devices

> with no screen at all, e.g. in the IM profile (as in

> my case at the moment) and still there's a need to

> process the stack trace somehow. Unfortunately, it

> seems to be not possible at all.

i explain...

you write some code with something critical...

try{

// i try something really critical

}catch(Exception e){

// create an Alert with the Exception message inside

// display the alert

Alert alert = new Alert (e.toString());

alert.setTimeout (Alert.FOREVER);

display.setCurrent (alert);

}

so when the critical code throws an Exception, the alert will be displayed

with the exception message inside and the application will not freeze

am i clear?

suparenoa at 2007-7-9 5:00:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 9

> so when the critical code throws an Exception, the

> alert will be displayed

> with the exception message inside and the application

> will not freeze

As said:

1. the message is useless in most cases. There was explicitly asked for the STACKTRACE!!! Nothing else.

2. Some devices do not have a display

deepspacea at 2007-7-9 5:00:01 > top of Java-index,Java Mobility Forums,Java ME Technologies...