public static TaskExecutionFailure failureFromException(@NotNull Exception e) { TaskExecutionFailureImplementationFault fault = new TaskExecutionFailureImplementationFault(); fault.setMessage(e.getMessage()); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); pw.close(); fault.setFaultTrace(sw.toString()); fault.setFaultClass(e.getClass().getName()); StackTraceElement[] se = e.getStackTrace(); if (se.length > 0) fault.setFaultLocation(se[0].toString()); TaskExecutionFailure tef = new TaskExecutionFailure(); tef.setImplementationFault(fault); return tef; }