Java Exception Format formatException(Throwable th)

Here you can find the source of formatException(Throwable th)

Description

Format the information from a Throwable as string, retaining the type and its message.

License

Open Source License

Parameter

Parameter Description
th the throwable to process

Return

string with the type of the Throwable and its message, e.g. "[IOException]: Could not open stream"

Declaration

public static String formatException(Throwable th) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from ww w  .  j a  v a 2s. c  o  m
     * Format the information from a Throwable as string, retaining the type and its message.
     *
     * @param th the throwable to process
     * @return string with the type of the Throwable and its message, e.g. "[IOException]: Could not open stream"
     */
    public static String formatException(Throwable th) {
        return "[" + th.getClass().getSimpleName() + "]: " + th.getMessage();
    }
}

Related

  1. fmtError( Exception e )
  2. formatException(final Exception e)
  3. formatException(Throwable ex)
  4. formatException(Throwable exception)
  5. formatExceptionMsg(String msg)
  6. formatJavaException(Exception e)
  7. formatLogMessage(long id, Throwable exception)
  8. formatMessage(Exception e)