Commit 86fd1903 authored by Quxl's avatar Quxl

x

parent 9ee3817b
...@@ -1161,6 +1161,8 @@ public class StringUtil { ...@@ -1161,6 +1161,8 @@ public class StringUtil {
return null; return null;
} else if(object instanceof Date) { } else if(object instanceof Date) {
return DateUtil.format((Date)object); return DateUtil.format((Date)object);
} else if(object instanceof Throwable) {
return toStackString((Throwable)object).toString();
} }
return object.toString(); return object.toString();
} }
...@@ -1169,4 +1171,22 @@ public class StringUtil { ...@@ -1169,4 +1171,22 @@ public class StringUtil {
return str1 == null ? str2 == null : str1.equals(str2); return str1 == null ? str2 == null : str1.equals(str2);
} }
public static StringBuffer toStackString(Throwable ex) {
StringBuffer stack = new StringBuffer();
if(ex != null) {
stack.append(ex.getClass().getName()).append(": ").append(ex.getMessage()).append(System.lineSeparator());
StackTraceElement[] elms = ex.getStackTrace();
for(StackTraceElement elm : elms) {
stack.append("\t").append(elm.getClassName()).append(".").append(elm.getMethodName()).append("(").append(elm.getFileName()).append(" ").append(elm.getLineNumber()).append(")\n");
}
if(ex.getCause() != null) {
stack.append("\n\n").append("Cause By: \n").append(toStackString(ex.getCause()));
}
for(Throwable e : ex.getSuppressed()) {
stack.append("\n\n").append("Suppressed By: \n").append(toStackString(e));
}
}
return stack;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment