Development Shack Technology Understood

A Better Java Exception toString()  

This is a simple example of how to build a String with the stack trace of the Exception or Throwable:

Exception e;
String message = e.getMessage() + "\n";
for (StackTraceElement element : e.getStackTrace()) {
    String line = String.format("\t%s.%s:%d [%d]", element.getClassName(), element.getMethodName(), element.getLineNumber(), element.getFileName());
    message += line + "\n";
}