diff --git a/src/tap/ADQLExecutor.java b/src/tap/ADQLExecutor.java index 8ad271fded6862bd545759eb635f7b3f3d1ff2a0..96f18fc0de738ac09d75fbf7d2e6468381b7cc05 100644 --- a/src/tap/ADQLExecutor.java +++ b/src/tap/ADQLExecutor.java @@ -530,7 +530,7 @@ public class ADQLExecutor { */ protected TableIterator executeADQL(final ADQLQuery adql) throws InterruptedException, TAPException{ // Log the start of execution: - logger.logTAP(LogLevel.INFO, report, "EXECUTING", "Executing ADQL: " + adql.toString().replaceAll("(\t|\r?\n)+", " "), null); + logger.logTAP(LogLevel.INFO, report, "EXECUTING", "Executing ADQL: " + adql.toADQL().replaceAll("(\t|\r?\n)+", " "), null); // Execute the ADQL query: TableIterator result = dbConn.executeQuery(adql); diff --git a/src/tap/log/DefaultTAPLog.java b/src/tap/log/DefaultTAPLog.java index 441a8f0ccb1d1eadf669bcf90ccc5187170fa89d..f20e6fa52dc7f7c5b256d46b00e6efbb9012b709 100644 --- a/src/tap/log/DefaultTAPLog.java +++ b/src/tap/log/DefaultTAPLog.java @@ -22,6 +22,7 @@ package tap.log; import java.io.OutputStream; import java.io.PrintWriter; +import java.sql.SQLException; import tap.TAPExecutionReport; import tap.TAPSyncJob; @@ -88,7 +89,18 @@ public class DefaultTAPLog extends DefaultUWSLog implements TAPLog { @Override public void logDB(final LogLevel level, final DBConnection connection, final String event, final String message, final Throwable error){ + // log the main given error: log(level, "DB", event, (connection != null ? connection.getID() : null), message, error); + + /* Some SQL exceptions (like BatchUpdateException) have a next exception which provides more information. + * Here, the stack trace of the next exception is also logged: + */ + if (error != null && error instanceof SQLException && ((SQLException)error).getNextException() != null){ + PrintWriter out = getOutput(level, "DB"); + out.println("[NEXT EXCEPTION]"); + ((SQLException)error).getNextException().printStackTrace(out); + out.flush(); + } } @Override diff --git a/src/uws/UWSException.java b/src/uws/UWSException.java index 00359606ef63e0d8aa6d7a4b68172702df6c64a6..1128170787158f9fce238957481b1f091404d25b 100644 --- a/src/uws/UWSException.java +++ b/src/uws/UWSException.java @@ -139,7 +139,7 @@ public class UWSException extends Exception { * @param t The thrown (and so caught) exception. */ public UWSException(int httpError, Throwable t){ - this(httpError, t, null, null); + this(httpError, t, (t != null) ? t.getMessage() : null, null); } /** @@ -151,7 +151,7 @@ public class UWSException extends Exception { * @param type Type of the error (FATAL or TRANSIENT). <i>Note: If NULL, it will be considered as FATAL.</i> */ public UWSException(int httpError, Throwable t, ErrorType type){ - this(httpError, t, null, type); + this(httpError, t, (t != null) ? t.getMessage() : null, type); } /** diff --git a/src/uws/job/UWSJob.java b/src/uws/job/UWSJob.java index 088fbfdf98420f315a1e07037148e3907f8f1357..c26bad838f2ba37d31aab4b4d7aa6641b3092513 100644 --- a/src/uws/job/UWSJob.java +++ b/src/uws/job/UWSJob.java @@ -575,7 +575,7 @@ public class UWSJob extends SerializableUWSObject { ExecutionPhase oldPhase = phase.getPhase(); phase.setPhase(p, force); - getLogger().logJob(LogLevel.INFO, this, "CHANGE_PHASE", "The job \"\" goes from " + oldPhase + " to " + p, null); + getLogger().logJob(LogLevel.INFO, this, "CHANGE_PHASE", "The job \"" + getJobId() + "\" goes from " + oldPhase + " to " + p, null); // Notify the execution manager: if (phase.isFinished() && getJobList() != null)