Java Utililty Methods Exception Print

List of utility methods to do Exception Print

Description

The list of methods to do Exception Print are organized into topic(s).

Method

voidprintException(Exception e)
Prints out the message of the exception.
System.err.println(e.getLocalizedMessage());
voidprintException(Exception e)
print Exception
System.out.println("Exception caught! Exiting ..");
System.out.println("error message: " + e.getMessage());
e.printStackTrace();
voidprintException(Exception e)
print Exception
StackTraceElement ste = null;
int i = 0;
while (i < e.getStackTrace().length && (ste = e.getStackTrace()[i++]).getLineNumber() == -1)
    ;
if (ste == null) {
    printError("Utilities.printException error: StackTraceElement ste is null");
    return;
String className = ste.getClassName();
String methodName = ste.getMethodName();
String fileName = ste.getFileName();
int lineNumber = ste.getLineNumber();
printError(e.toString());
printError("\tat " + className + "." + methodName + "(" + fileName + ":" + lineNumber + ")");
voidprintException(Exception e, String message)
Prints an error message with the exception stacktrace to the console with the prefix
EXCEPTION!
printInfo("EXCEPTION! " + message);
voidprintException(String excption)
print Exception
System.err.println(excption);
voidprintException(String prefix, Exception e)
print Exception
String message = (e == null) ? null : e.getMessage();
if ((message == null) && (e != null))
    message = e.getClass().getName();
System.err.println(prefix + message);
System.err.flush();
voidPrintException(StringBuilder Str, boolean HTML, Throwable T, boolean PrintCauseToo)
Print Exception
if (PrintCauseToo == true && T.getCause() != null) {
    PrintException(Str, HTML, T.getCause());
    if (HTML == true)
        Str.append("<BR>");
    Str.append("\n");
PrintException(Str, HTML, T);
voidprintException(Throwable e, StackTraceElement[] trace)
print Exception
StringBuilder out = new StringBuilder("--- Exception in Async Thread ---\n");
out.append(e.getClass().getName()).append(": ").append(e.getMessage()).append('\n');
StackTraceElement[] st = e.getStackTrace();
out.append(printTrace(st));
Throwable cause = e.getCause();
while (cause != null) {
    out.append(cause.getClass().getName()).append(": ").append(cause.getMessage()).append('\n');
    st = cause.getStackTrace();
...
voidprintExceptionInfo(Exception e)
print Exception Info
System.out.println(e.getClass().getName() + " Error: ");
System.out.println(e.getMessage() + "\n" + e.getStackTrace());
StringprintExceptionMessage(Throwable ex)
Return stack trace of the Throwable ex.
return printExceptionMessage(ex, 15);