mirror of https://github.com/apache/cloudstack.git
Add string util function to retrieve exception info
This commit is contained in:
parent
e902e83d13
commit
5d3052c05f
|
|
@ -19,7 +19,7 @@
|
|||
package com.cloud.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
// StringUtils exists in Apache Commons Lang, but rather than import the entire JAR to our system, for now
|
||||
|
|
@ -81,5 +81,20 @@ public class StringUtils {
|
|||
|
||||
return tags;
|
||||
}
|
||||
|
||||
|
||||
public static String getExceptionStackInfo(Throwable e) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
sb.append(e.toString()).append("\n");
|
||||
StackTraceElement[] elemnents = e.getStackTrace();
|
||||
for(StackTraceElement element : elemnents) {
|
||||
sb.append(element.getClassName()).append(".");
|
||||
sb.append(element.getMethodName()).append("(");
|
||||
sb.append(element.getFileName()).append(":");
|
||||
sb.append(element.getLineNumber()).append(")");
|
||||
sb.append("\n");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue