[New] Added StringHelper.formatException(Throwable)
This commit is contained in:
parent
adc9e3598c
commit
c969e25a85
|
@ -15,6 +15,8 @@
|
||||||
*/
|
*/
|
||||||
package ch.eitchnet.utils.helper;
|
package ch.eitchnet.utils.helper;
|
||||||
|
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
@ -551,6 +553,21 @@ public class StringHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formats the given {@link Throwable}'s stack trace to a string
|
||||||
|
*
|
||||||
|
* @param t
|
||||||
|
* the throwable for which the stack trace is to be formatted to string
|
||||||
|
*
|
||||||
|
* @return a string representation of the given {@link Throwable}'s stack trace
|
||||||
|
*/
|
||||||
|
public static String formatException(Throwable t) {
|
||||||
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
PrintWriter writer = new PrintWriter(stringWriter);
|
||||||
|
t.printStackTrace(writer);
|
||||||
|
return stringWriter.toString();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simply returns true if the value is null, or empty
|
* Simply returns true if the value is null, or empty
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue