cancel
Showing results for 
Search instead for 
Did you mean: 

regarding reporting exception

Former Member
0 Kudos

Hi forum,

I want to show an exception message in 3 lines as follows in my project ie 1st line print :Error occured while proccessing

2nd line: error code

3rd line:error stack trace:(exception)

I tried using the new line character ie

wdThis

.wdGetAPI()

.getComponent()

.getMessageManager()

.reportException("Problem occured while processing Agency Fee. Please contact the System Administrator.""\r\n"exceptionId"\r\nStack Trace:"exception,false);

but this is not working. Is there possible way to do this?

Else another alternate would be printing 3 report exception but it will contain 3 error symbols for one error message.

Thanks & Regards

Jaspreet Kaur Grewal

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi jaspreet,

try using StackTraceElement for this. get the Array of StackTraceElement from the exception & print that in a loop. So u can append ur custom message also with the exception

StackTraceElement[] stack = ex.getStackTrace();

regards

Sumit

Former Member
0 Kudos

Hi Sumit,

I didn't get u can u please elaborate by an example.

Thanks & Regards

Jaspreet Kaur Grewal

Former Member
0 Kudos

Hi Jaspreet,

it should be something like this

try

{

}

catch(Exception ex)

{

show ur custom message

StackTraceElement[] stack = ex.getStackTrace();

for(int a=0;a<stack.length; a++)

{

u can print the trace here in different lines

}

}

regards

Sumit

Former Member
0 Kudos

Hi Sumit

To Print the stack trace wud i be using report xeception or there is another way to do so.

I used ex.printstacktrace()

but this is not solving any purpose.

Thanks & Regards

Jaspreet Kaur

Edited by: Jaspreet Kaur Grewal on Jan 16, 2008 12:11 PM

Andrzej_Filusz
Contributor
0 Kudos

Hi!

I think this simple function below will be useful to you:

public static String stackTraceToString(Throwable th){

StringWriter strWr = new StringWriter();

PrintWriter prWr = new PrintWriter(strWr);

th.printStackTrace(prWr);

strWr.flush();

prWr.flush();

return strWr.toString();

}

Regards,

Andrzej