Here you can find the source of formatException(Throwable ex)
Returns a formatted string in the java style exception format.
Parameter | Description |
---|---|
ex | - the exception to format |
ex
as a formatted text
public static String formatException(Throwable ex)
//package com.java2s; public class Main { /**/*from w w w .jav a 2s. c o m*/ * <p>Returns a formatted string in the java style exception format.</p> * * @param ex - the exception to format * @return the specified exception <code>ex</code> as a formatted text {@link String} */ public static String formatException(Throwable ex) { StringBuilder sb = new StringBuilder(); sb.append(ex.getMessage()); sb.append("\n"); StackTraceElement[] trace = ex.getStackTrace(); for (int i = 0; i < trace.length; i++) { sb.append("\t"); sb.append(trace[i]); sb.append("\n"); } return sb.toString(); } }