List of utility methods to do Throwable to String
String | getExceptionDescription(Throwable e) Get the message + stack trace associated with this exception. try { StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); try { e.printStackTrace(printWriter); return stringWriter.getBuffer().toString(); } finally { stringWriter.close(); ... |
String | getExceptionDetails(final Throwable e) get Exception Details return getExceptionDetails(e, ""); |
String | getExceptionDetails(Throwable throwable) Get exception information as a string. StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.println("Exception: "); throwable.printStackTrace(pw); return sw.toString(); |
String | getExceptionHeadline(Throwable t) get Exception Headline Pattern pattern = Pattern.compile("([\\w\\.]+)(:.*)?"); String stackTrace = getStackTrace(t); Matcher matcher = pattern.matcher(stackTrace); if (matcher.find()) return matcher.group(1); return null; |
String | getExceptionPrintout(Throwable aThrowable) Defines a custom format for the stack trace as String. final StringBuilder result = new StringBuilder(); result.append(aThrowable.toString()); final String NEW_LINE = System.getProperty("line.separator"); result.append(NEW_LINE); for (StackTraceElement element : aThrowable.getStackTrace()) { result.append(element); result.append(NEW_LINE); return result.toString(); |
String | getExceptionStack(final Throwable e) get Exception Stack java.io.StringWriter wSW = new java.io.StringWriter(); e.printStackTrace(new java.io.PrintWriter(wSW)); return wSW.toString(); |
String | getExceptionStack(Throwable e) get Exception Stack String msg = e.getMessage(); try { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); msg = sw.toString(); } catch (Throwable e2) { msg = "bad getErrorInfoFromException"; ... |
String | getExceptionStackTrace(Throwable ex) get Exception Stack Trace StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); pw.close(); return sw.toString(); |
String | getExceptionStackTrace(Throwable exception) get Exception Stack Trace if (null == exception) throw new IllegalArgumentException("exception can't be null;"); String stack_trace; StringWriter string_writer = new StringWriter(); try (PrintWriter print_writer = new PrintWriter(string_writer)) { exception.printStackTrace(print_writer); stack_trace = string_writer.getBuffer().toString(); return stack_trace; |
String | getExceptionStackTrace(Throwable exception) Obtains the entire stracktrace of an exception and converts it into a string. if (null == exception) throw new IllegalArgumentException("exception can't be null;"); String stack_trace = null; StringWriter string_writer = new StringWriter(); PrintWriter print_writer = new PrintWriter(string_writer); exception.printStackTrace(print_writer); stack_trace = string_writer.getBuffer().toString(); print_writer.close(); ... |