| | |
| | | * |
| | | * @param throwable |
| | | * The exception for which to retrieve the stack trace. |
| | | * @param isDebug |
| | | * @param isFullStack |
| | | * If {@code true}, provides the full stack trace, otherwise |
| | | * provides a limited extract of stack trace |
| | | * @return A stack trace from the provided exception as a single-line |
| | | * string. |
| | | */ |
| | | public static String stackTraceToSingleLineString(Throwable throwable, boolean isDebug) { |
| | | public static String stackTraceToSingleLineString(Throwable throwable, boolean isFullStack) { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | stackTraceToSingleLineString(buffer, throwable, isDebug); |
| | | stackTraceToSingleLineString(buffer, throwable, isFullStack); |
| | | return buffer.toString(); |
| | | } |
| | | |
| | |
| | | * The buffer to which the information is to be appended. |
| | | * @param throwable |
| | | * The exception for which to retrieve the stack trace. |
| | | * @param isDebug |
| | | * @param isFullStack |
| | | * If {@code true}, provides the full stack trace, otherwise |
| | | * provides a limited extract of stack trace |
| | | */ |
| | | public static void stackTraceToSingleLineString(StringBuilder buffer, Throwable throwable, boolean isDebug) { |
| | | public static void stackTraceToSingleLineString(StringBuilder buffer, Throwable throwable, boolean isFullStack) { |
| | | if (throwable == null) { |
| | | return; |
| | | } |
| | | if (isDebug) { |
| | | if (isFullStack) { |
| | | buffer.append(throwable); |
| | | // add first-level stack trace |
| | | for (StackTraceElement e : throwable.getStackTrace()) { |
| | |
| | | buffer.append(e.getLineNumber()); |
| | | i++; |
| | | } |
| | | |
| | | buffer.append(")"); |
| | | } |
| | | } |