Java SQLException exceptionMsg2LocalizedStr(final Throwable e)

Here you can find the source of exceptionMsg2LocalizedStr(final Throwable e)

Description

exception Msg Localized Str

License

Apache License

Declaration

public static final String exceptionMsg2LocalizedStr(final Throwable e) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.sql.SQLException;

public class Main {

    public static final String exceptionMsg2LocalizedStr(final Throwable e) {
        if (e == null)
            return null;
        String message = e.getLocalizedMessage();
        if (message == null)
            message = e.getClass().getName();

        if (e instanceof SQLException) {
            SQLException nextException = ((SQLException) e).getNextException();
            if (nextException != null)
                message += "\r\n" + exceptionMsg2str(nextException);
        }//  w w  w  . j a va  2 s . c o m
        return message;
    }

    public static final String exceptionMsg2str(final Throwable e) {
        if (e == null)
            return null;
        String message = e.getMessage();
        if (message == null)
            message = e.getClass().getName();

        if (e instanceof SQLException) {
            SQLException nextException = ((SQLException) e).getNextException();
            if (nextException != null)
                message += "\r\n" + exceptionMsg2str(nextException);
        }
        return message;
    }
}

Related

  1. appendToExceptionList(List list, SQLException sqlException)
  2. convertSQLExceptionToString(SQLException e)
  3. createFeatureNotSupportedException()
  4. exceptionMsg2str(final Throwable e)
  5. exceptionToString(Throwable e)
  6. extractErrorCode(SQLException sqlException)
  7. extractNestedSQLExceptions( SQLException exception)