-1

Lets say I have a function like this

public JSONObject parseMessage(InputStream fileName) throws Exception { 

And it throws an error where can I get the stack trace of that?

I know if I have something like

try {} catch(Exception e) {//I could save it to a var here}

But how to I save the stacktrace to are variable with a function that throws Exception?

Thanks for all the help

iqueqiorio
  • 1,149
  • 2
  • 35
  • 78

1 Answers1

0

You can use Apache commons to convert an Exception stack trace to String.

This class is available in Apache commons-lang-2.2.jar:

org.apache.commons.lang.exception.ExceptionUtils.getStackTrace(Throwable)
Sundararaj Govindasamy
  • 8,180
  • 5
  • 44
  • 77