Skip to content
Permalink
Browse files

0003865: Improve logging readability and appropriate levels

  • Loading branch information...
elong
elong committed Mar 6, 2019
1 parent 1c1bcb2 commit 8c5984a4e10293545320c0e4b85911da41859a67
@@ -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;
@@ -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);
}
}
@@ -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);
}

}
@@ -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;
@@ -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 {
@@ -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");

0 comments on commit 8c5984a

Please sign in to comment.
You can’t perform that action at this time.