docs: public static SQLException getException(SQLException exception, MariaDbConnection connection,
        MariaDbStatement statement, boolean timeout) {
      final StringBuilder message;
      String errMsg = exception.getMessage();
      if (errMsg.contains("\n")) {
        errMsg = errMsg.substring(0, errMsg.indexOf("\n"));
      }
      if (connection != null) {
        message = new StringBuilder("(conn=")
            .append(connection.getServerThreadId())
            .append(") ")
            .append(errMsg);
      } else if (statement != null) {
        message = new StringBuilder("(conn=")
            .append(statement.getServerThreadId())
            .append(") ")
            .append(errMsg);
      } else {
        message = new StringBuilder(errMsg);
      }
  
      SQLException sqlException;
      SqlStates state = null;
  
      if (exception.getSQLState() != null) {
        if (connection != null
            && exception.getSQLState() != null
            && LOCK_DEADLOCK_ERROR_CODES.contains(exception.getErrorCode())) {
  
          if (connection.includeDeadLockInfo()) {
            try {
              Statement stmt = connection.createStatement();
              ResultSet rs = stmt.executeQuery("SHOW ENGINE INNODB STATUS");
              if (rs.next()) {
                message.append("\ndeadlock information: ")
                    .append(rs.getString(3));
              }
            } catch (SQLException sqle) {
              //eat
            }
          }
  
          if (connection.includeThreadsTraces()) {
            message.append("\n\ncurrent threads: ");
            Thread.getAllStackTraces().forEach((thread, traces) -> {
              message.append("\n  name:\"")
                  .append(thread.getName())
                  .append("\" pid:")
                  .append(thread.getId())
                  .append(" status:")
                  .append(thread.getState());
              for (int i = 0; i < traces.length; i++) {
                message.append("\n    ").append(traces[i]);
              }
            });
          }
        }
        sqlException = get(message.toString(), exception.getSQLState(), exception.getErrorCode(),
            exception, timeout);
        String sqlState = exception.getSQLState();
        state = SqlStates.fromString(sqlState);
        SQLException nextException = exception.getNextException();
        if (nextException != null) {
          sqlException.setNextException(nextException);
        }
      } else {
        sqlException = exception;
      }
  
      if (connection != null) {
        if (SqlStates.CONNECTION_EXCEPTION.equals(state)) {
          connection.setHostFailed();
          if (connection.pooledConnection != null) {
            connection.pooledConnection.fireConnectionErrorOccured(sqlException);
          }
        } else if (connection.pooledConnection != null && statement != null) {
          connection.pooledConnection.fireStatementErrorOccured(statement, sqlException);
        }
      }
  
      return sqlException;
    }