java/code/src/com/redhat/rhn/taskomatic/task/RhnJavaJob.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
New commits:
commit d6a6ad7c0cda0c077e4c4d52f7332cbdfcb1fcd2
Author: Silvio Moioli <smoioli(a)suse.de>
Date: Tue Sep 24 14:55:24 2013 +0200
Add exception stack trace logging in Taskomatic
Some extra information was added to the Taskomatic error log if an unexpected
exception gets thrown in task code. Previously only cause and message were
printed, which could be insufficient information to do proper debugging
(notably, NullPointerExceptions by default have null message and cause,
making them hard to track down).
diff --git a/java/code/src/com/redhat/rhn/taskomatic/task/RhnJavaJob.java
b/java/code/src/com/redhat/rhn/taskomatic/task/RhnJavaJob.java
index 22073e3..61177fb 100644
--- a/java/code/src/com/redhat/rhn/taskomatic/task/RhnJavaJob.java
+++ b/java/code/src/com/redhat/rhn/taskomatic/task/RhnJavaJob.java
@@ -26,6 +26,8 @@ import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.Arrays;
@@ -65,8 +67,13 @@ public abstract class RhnJavaJob implements RhnJob {
* {@inheritDoc}
*/
public void appendExceptionToLogError(Exception e) {
- log.error(e.getMessage());
- log.error(e.getCause());
+ log.error("Executing a task threw an exception: " +
e.getClass().getName());
+ log.error("Message: " + e.getMessage());
+ log.error("Cause: " + e.getCause());
+
+ StringWriter errors = new StringWriter();
+ e.printStackTrace(new PrintWriter(errors));
+ log.error("Stack trace:" + errors.toString());
}
/**
Show replies by date