ExceptionUtils { public static String toShortString(Throwable e, int stackLevel) { StackTraceElement[] traces = e.getStackTrace(); StringBuilder sb = new StringBuilder(1024); sb.append(e.toString()).append("\t"); if (traces != null) { for (int i = 0; i < traces.length; i++) { if (i < stackLevel) { sb.append("\tat ").append(traces[i]).append("\t"); } else { break; } } } return sb.toString(); }  static SofaRpcRuntimeException buildRuntime(String configKey, String configValue); static SofaRpcRuntimeException buildRuntime(String configKey, String configValue, String message); static boolean isServerException(SofaRpcException exception); static boolean isClientException(SofaRpcException exception); static String toString(Throwable e); static String toShortString(Throwable e, int stackLevel);  }
@Test public void toShortString() throws Exception { SofaRpcException exception = new SofaRpcException(RpcErrorType.SERVER_BUSY, "111"); String string = ExceptionUtils.toShortString(exception, 1); Assert.assertNotNull(string); Pattern pattern = Pattern.compile("at"); Matcher matcher = pattern.matcher(string); int count = 0; while (matcher.find()) { count++; } Assert.assertTrue(count == 1); }