Skip to content

Commit

Permalink
Improve error reporting in ancestry estimation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukfor committed Dec 10, 2023
1 parent bff1edf commit 9e9a05b
Showing 1 changed file with 23 additions and 27 deletions.
50 changes: 23 additions & 27 deletions src/main/java/genepi/imputationserver/steps/ancestry/TraceStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,9 @@ public boolean prepareTraceJobs(WorkflowContext context) {
return true;

} catch (IOException e) {
context.error("An internal server error occured.");
e.printStackTrace();

context.error("An internal server error occurred.\n" + exceptionToString(e));

}

context.error("Execution failed. Please, contact administrator.");
Expand Down Expand Up @@ -209,8 +210,7 @@ public boolean checkDataAndMerge(WorkflowContext context, String[] files, String
return true;

} catch (IOException e) {
context.error("Input Validation failed: " + e);
e.printStackTrace();
context.error("Input Validation failed:\n" + exceptionToString(e));
return false;
}
}
Expand Down Expand Up @@ -289,17 +289,7 @@ public boolean estimateAncestries(WorkflowContext context) {
return true;

} catch (IOException e) {
context.error("An internal server error occured while launching Hadoop job.");
e.printStackTrace();
} catch (InterruptedException e) {
context.error("An internal server error occured while launching Hadoop job.");
e.printStackTrace();
} catch (ClassNotFoundException e) {
context.error("An internal server error occured while launching Hadoop job.");
e.printStackTrace();
} catch (URISyntaxException e) {
context.error("An internal server error occured while launching Hadoop job.");
e.printStackTrace();
context.error("An internal server error occurred while launching Hadoop job.\n" + exceptionToString(e));
}

context.error("Execution failed. Please, contact administrator.");
Expand All @@ -326,37 +316,43 @@ public void progress(String message) {
}
return results;
} catch (InterruptedException e) {
e.printStackTrace();
TaskResults result = new TaskResults();
result.setSuccess(false);
result.setMessage(e.getMessage());
StringWriter s = new StringWriter();
e.printStackTrace(new PrintWriter(s));
context.println("Task '" + task.getName() + "' failed.\nException:" + s.toString());
context.println("Task '" + task.getName() + "' failed.\nException:" + exceptionToString(e));
context.endTask(e.getMessage(), WorkflowContext.ERROR);
return result;
} catch (Exception e) {
e.printStackTrace();
TaskResults result = new TaskResults();
result.setSuccess(false);
result.setMessage(e.getMessage());
StringWriter s = new StringWriter();
e.printStackTrace(new PrintWriter(s));
context.println("Task '" + task.getName() + "' failed.\nException:" + s.toString());
context.println("Task '" + task.getName() + "' failed.\nException:" + exceptionToString(e));
context.endTask(task.getName() + " failed.", WorkflowContext.ERROR);
return result;
} catch (Error e) {
e.printStackTrace();
TaskResults result = new TaskResults();
result.setSuccess(false);
result.setMessage(e.getMessage());
StringWriter s = new StringWriter();
e.printStackTrace(new PrintWriter(s));
context.println("Task '" + task.getName() + "' failed.\nException:" + s.toString());
context.println("Task '" + task.getName() + "' failed.\nException:" + exceptionToString(e));
context.endTask(task.getName() + " failed.", WorkflowContext.ERROR);
return result;
}

}

private static String exceptionToString(Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
return sw.toString();
}

private static String exceptionToString(Error e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
return sw.toString();
}

}

0 comments on commit 9e9a05b

Please sign in to comment.