DataBundles extends Bundles { public static ErrorDocument getError(Path path) throws IOException { if (path == null) return null; Path errorPath = withExtension(path, DOT_ERR); List<String> errorList = readAllLines(errorPath, UTF8); int split = errorList.indexOf(""); if (split == -1 || errorList.size() <= split) throw new IOException("Invalid error document: " + errorPath); ErrorDocument errorDoc = new ErrorDocument(); for (String cause : errorList.subList(0, split)) errorDoc.getCausedBy().add(path.resolveSibling(cause)); errorDoc.setMessage(errorList.get(split + 1)); StringBuilder errorTrace = new StringBuilder(); for (String line : errorList.subList(split + 2, errorList.size())) { errorTrace.append(line); errorTrace.append("\n"); } if (errorTrace.length() > 0) errorTrace.deleteCharAt(errorTrace.length() - 1); errorDoc.setTrace(errorTrace.toString()); return errorDoc; }  static void createList(Path path); static void deleteAllExtensions(final Path file); static ErrorDocument getError(Path path); static Path getInputs(Bundle dataBundle); static List<Path> getList(Path list); static Path getListItem(Path list, long position); static Path getOutputs(Bundle dataBundle); static Path getPort(Path map, String portName); static NavigableMap<String, Path> getPorts(Path path); static boolean hasInputs(Bundle dataBundle); static boolean hasOutputs(Bundle dataBundle); static boolean isError(Path path); static boolean isList(Path path); static boolean isMissing(Path item); static boolean isValue(Path item); static Path newListItem(Path list); static Path setError(Path path, ErrorDocument error); static Path setError(Path errorPath, String message, String trace,
			Path... causedBy); static Path setReference(Path path, URI reference); static void setStringValue(Path path, String string); static Path getWorkflowRunProvenance(Bundle dataBundle); static Path getWorkflowRunReport(Bundle dataBundle); static JsonNode getWorkflowRunReportAsJson(Bundle dataBundle); static void setWorkflowRunReport(Bundle dataBundle,
			JsonNode workflowRunReport); static Path getWorkflow(Bundle dataBundle); static Path getWorkflowDescription(Bundle dataBundle); static void setWorkflowBundle(Bundle dataBundle,
			WorkflowBundle wfBundle); static WorkflowBundle getWorkflowBundle(Bundle dataBundle); static Path getIntermediates(Bundle dataBundle); static Path getIntermediate(Bundle dataBundle, UUID uuid); static long getListSize(Path list); @SuppressWarnings({ "unchecked", "rawtypes" }) static Object resolve(Path path, ResolveOptions... options); static Stream<T> resolveAsStream(Path path, Class<T> type); static WorkflowBundleIO getWfBundleIO(); static void setWfBundleIO(WorkflowBundleIO wfBundleIO);  }
@Test public void getError() throws Exception { Path inputs = DataBundles.getInputs(dataBundle); Path portIn1 = DataBundles.getPort(inputs, "in1"); DataBundles.setError(portIn1, "Something did not work", "A very\n long\n error\n trace"); ErrorDocument error = DataBundles.getError(portIn1); assertTrue(error.getCausedBy().isEmpty()); assertEquals("Something did not work", error.getMessage()); assertEquals("A very\n long\n error\n trace", error.getTrace()); assertEquals(null, DataBundles.getError(null)); }