public static void surfaceSqlException(SQLException e){
  boolean chained=false;
  String loggerMsg;
  while (e != null) {
    if (chained) {
      loggerMsg=String.format("Next in SQLException chain:  State=%s, ErrorCode=%d, Message=(%s)\n%s",e.getSQLState(),e.getErrorCode(),e.getMessage(),stackTraceToString(e));
    }
 else {
      loggerMsg=String.format("SQLException:  State=%s, ErrorCode=%d, Message=(%s)\n%s",e.getSQLState(),e.getErrorCode(),e.getMessage(),stackTraceToString(e));
      chained=true;
    }
    e=e.getNextException();
    logger.error(loggerMsg);
  }
}

public static void surfaceSqlException ( SQLException e ) { boolean chained = false ; String loggerMsg ; while ( e != null ) { if ( chained ) { loggerMsg = String . format ( "Next in SQLException chain:  State=%s, ErrorCode=%d, Message=(%s)\n%s" , e . getSQLState ( ) , e . getErrorCode ( ) , e . getMessage ( ) , stackTraceToString ( e ) ) ; } else { loggerMsg = String . format ( "SQLException:  State=%s, ErrorCode=%d, Message=(%s)\n%s" , e . getSQLState ( ) , e . getErrorCode ( ) , e . getMessage ( ) , stackTraceToString ( e ) ) ; chained = true ; } e = e . getNextException ( ) ; logger . error ( loggerMsg ) ; } }
surface a string describing a sql exception via this class ' logger . since sql exceptions typically have a chain of related exceptions , do the same for these . this chaining appears to superscede the normal exception " causedby " paradigm .
