Skip to content

Commit

Permalink
Revert "Too big error message JabRef#4827"
Browse files Browse the repository at this point in the history
This reverts commit d249da1
  • Loading branch information
dpolishc committed May 12, 2019
1 parent 331d4b8 commit cf514d0
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/main/java/org/jabref/logic/shared/DBMSConnection.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
package org.jabref.logic.shared;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;

import org.jabref.logic.l10n.Localization;
import org.jabref.logic.shared.exception.InvalidDBMSConnectionPropertiesException;
import org.jabref.model.database.shared.DBMSType;
import org.jabref.model.database.shared.DatabaseConnection;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;

public class DBMSConnection implements DatabaseConnection {

private static final Logger LOGGER = LoggerFactory.getLogger(DBMSConnection.class);
Expand All @@ -37,12 +38,9 @@ public DBMSConnection(DBMSConnectionProperties connectionProperties) throws SQLE
} catch (SQLException e) {
// Some systems like PostgreSQL retrieves 0 to every exception.
// Therefore a stable error determination is not possible.
String message = e.getMessage();
int endIndex = message.indexOf(".") != -1 ? message.indexOf(".") : message.length();
String errorMessagee = e.getSQLState().equals("01S00") ? message.substring(0, endIndex) : message;
LOGGER.error("Could not connect to database: " + message + " - Error code: " + e.getErrorCode());
LOGGER.error("Could not connect to database: " + e.getMessage() + " - Error code: " + e.getErrorCode());

throw new SQLException(errorMessagee, e);
throw e;
}
}

Expand Down

0 comments on commit cf514d0

Please sign in to comment.