Skip to content

Commit

Permalink
0003865: Improve logging readability and appropriate levels
Browse files Browse the repository at this point in the history
  • Loading branch information
elong committed Mar 6, 2019
1 parent 1c1bcb2 commit 8c5984a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
Expand Up @@ -31,6 +31,7 @@
import org.jumpmind.db.model.Table;
import org.jumpmind.db.sql.ISqlTemplate;
import org.jumpmind.db.sql.ISqlTransaction;
import org.jumpmind.db.sql.TableNotFoundException;
import org.jumpmind.db.sql.UniqueKeyException;
import org.jumpmind.exception.IoException;
import org.jumpmind.symmetric.ISymmetricEngine;
Expand Down Expand Up @@ -257,7 +258,9 @@ public void batchInError(DataContext context, Throwable ex) {
this.currentBatch.setSqlMessage(ExceptionUtils.getRootMessage(ex));
}

if (this.currentBatch.getSqlCode() != ErrorConstants.FK_VIOLATION_CODE || !isNewErrorForCurrentBatch) {
if (ex instanceof TableNotFoundException) {
log.error(String.format("The incoming batch %s failed: %s", this.currentBatch.getNodeBatchId(), ex.getMessage()));
} else if (this.currentBatch.getSqlCode() != ErrorConstants.FK_VIOLATION_CODE || !isNewErrorForCurrentBatch) {
log.error(String.format("Failed to load batch %s", this.currentBatch.getNodeBatchId()), ex);
}
}
Expand Down
@@ -0,0 +1,11 @@
package org.jumpmind.db.sql;

public class TableNotFoundException extends SqlException {

private static final long serialVersionUID = 1L;

public TableNotFoundException(String columnName) {
super(columnName);
}

}
Expand Up @@ -30,6 +30,7 @@
import org.jumpmind.db.model.Column;
import org.jumpmind.db.model.Table;
import org.jumpmind.db.sql.SqlException;
import org.jumpmind.db.sql.TableNotFoundException;
import org.jumpmind.exception.ParseException;
import org.jumpmind.symmetric.io.IoConstants;
import org.jumpmind.symmetric.io.data.Batch;
Expand Down Expand Up @@ -143,7 +144,7 @@ public void write(CsvData data) {
|| batch.getBatchId() == IoConstants.IGNORE_TABLES_BATCH)) {
String qualifiedName = sourceTable.getFullyQualifiedTableName();
if (!missingTables.contains(qualifiedName)) {
log.warn("Did not find the {} table in the target database", qualifiedName);
log.info("Did not find the {} table in the target database", qualifiedName);
missingTables.add(qualifiedName);
}
} else {
Expand Down Expand Up @@ -260,7 +261,7 @@ public void write(CsvData data) {
if (sourceTable != null) {
// If the source table was found but the target table is
// still unknown throw an exception
throw new SqlException(String.format("Could not find the target table '%s'",
throw new TableNotFoundException(String.format("Could not find the target table '%s'",
sourceTable.getFullyQualifiedTableName()));
} else {
throw new SqlException("The target table was not specified");
Expand Down

0 comments on commit 8c5984a

Please sign in to comment.