Skip to content

Instantly share code, notes, and snippets.

@parzonka
Created December 16, 2013 16:15
Show Gist options
  • Save parzonka/7989659 to your computer and use it in GitHub Desktop.
Save parzonka/7989659 to your computer and use it in GitHub Desktop.
Gets the stack trace from the given throwable.
/**
* Gets the stack trace from the given throwable.
*
* @param throwable
* a throwable
* @return stack trace as string
*/
public static String getStackTrace(Throwable throwable) {
final StringWriter stringWriter = new StringWriter();
throwable.printStackTrace(new PrintWriter(stringWriter));
return stringWriter.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment