View Code
1 public static String getExceptionStack(Exception e) { 2 StackTraceElement[] stackTraceElements = e.getStackTrace(); 3 String result = e.toString() + "\n"; 4 for (int index = stackTraceElements.length - 1; index >= 0; --index) { 5 result += "at [" + stackTraceElements[index].getClassName() + ","; 6 result += stackTraceElements[index].getFileName() + ","; 7 result += stackTraceElements[index].getMethodName() + ","; 8 result += stackTraceElements[index].getLineNumber() + "]\n"; 9 } 10 return result; 11 }