mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
allow controllable stack dump in ExceptionUtil.java
This commit is contained in:
parent
7ce9845fb7
commit
6ff40b7e88
@ -22,12 +22,19 @@ import java.io.StringWriter;
|
||||
|
||||
public class ExceptionUtil {
|
||||
public static String toString(Throwable th) {
|
||||
return toString(th, true);
|
||||
}
|
||||
|
||||
public static String toString(Throwable th, boolean printStack) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
writer.append("Exception: " + th.getClass().getName() + "\n");
|
||||
writer.append("Message: ");
|
||||
writer.append(th.getMessage());
|
||||
writer.append("\n Stack: ");
|
||||
th.printStackTrace(new PrintWriter(writer));
|
||||
writer.append(th.getMessage()).append("\n");
|
||||
|
||||
if(printStack) {
|
||||
writer.append("Stack: ");
|
||||
th.printStackTrace(new PrintWriter(writer));
|
||||
}
|
||||
return writer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user