ExceptionHelper { public static String getStackTrace(Throwable throwable, boolean isHtmlStyle) { AssertHelper.notNull(throwable, "throwable can't be null."); String line = isHtmlStyle ? "<br/>" : "\r\n"; String tab = isHtmlStyle ? "&nbsp;&nbsp;&nbsp;&nbsp;" : "\t"; while (throwable instanceof NiubiException) { throwable = throwable.getCause(); } StringBuffer stringBuffer = new StringBuffer(throwable.getClass().getName()).append(":"); if (throwable.getMessage() != null) { stringBuffer.append(throwable.getMessage()).append(line); } else { stringBuffer.append(line); } try { StackTraceElement[] stackElements = throwable.getStackTrace(); if (stackElements != null) { for (int i = 0; i < stackElements.length && i < MAX_STACK_TRACE_DEEP; i++) { stringBuffer.append(tab); stringBuffer.append(stackElements[i].getClassName()).append('.'); stringBuffer.append(stackElements[i].getMethodName()).append('('); stringBuffer.append(stackElements[i].getFileName()).append(':'); stringBuffer.append(stackElements[i].getLineNumber()).append(')'); stringBuffer.append(line); } } } catch (Exception e) { } if (isHtmlStyle) { return stringBuffer.length() > MAX_LENGTH ? (stringBuffer.substring(0, stringBuffer.lastIndexOf(line)) + DEFAULT_END_STRING) : stringBuffer.toString(); } else { return stringBuffer.length() > MAX_LENGTH ? (stringBuffer.substring(0, MAX_LENGTH) + DEFAULT_END_STRING) : stringBuffer.toString(); } }  static String getStackTrace(Throwable throwable, boolean isHtmlStyle); static String getStackTrace(Throwable throwable); static String getStackTrace();  }
@Test public void getStackTrace() { ExceptionHelper.getStackTrace(); }