private void processExceptions(TaskRunnable[] runnables) { if (runnables == null) { return; } for (TaskRunnable runnable : runnables) { Throwable t = runnable.getException(); if (t != null) { numExceptions++; if (firstException == null) { firstException = t; } if (t instanceof BuildException && firstLocation == Location.UNKNOWN_LOCATION) { firstLocation = ((BuildException) t).getLocation(); } if (t instanceof ExitStatusException && firstExitStatus == null) { ExitStatusException ex = (ExitStatusException) t; firstExitStatus = ex.getStatus(); // potentially overwriting existing value but the // location should match the exit status firstLocation = ex.getLocation(); } exceptionMessage.append(System.lineSeparator()); exceptionMessage.append(t.getMessage()); } } }
/** * Add location to build exception. * @param ex the build exception, if the build exception * does not include * @param newLocation the location of the calling task (may be null) * @return a new build exception based in the build exception with * location set to newLocation. If the original exception * did not have a location, just return the build exception */ public static BuildException addLocationToBuildException( BuildException ex, Location newLocation) { if (ex.getLocation() == null || ex.getMessage() == null) { return ex; } String errorMessage = String.format("The following error occurred while executing this line:%n%s%s", ex.getLocation().toString(), ex.getMessage()); if (ex instanceof ExitStatusException) { int exitStatus = ((ExitStatusException) ex).getStatus(); if (newLocation == null) { return new ExitStatusException(errorMessage, exitStatus); } return new ExitStatusException(errorMessage, exitStatus, newLocation); } if (newLocation == null) { return new BuildException(errorMessage, ex); } return new BuildException(errorMessage, ex, newLocation); }
if (t instanceof BuildException) { BuildException be = (BuildException) t; if (be.getLocation() == Location.UNKNOWN_LOCATION) { be.setLocation(location);
if (t instanceof BuildException) { BuildException be = (BuildException) t; if (be.getLocation() == Location.UNKNOWN_LOCATION) { be.setLocation(location);
throw ex; case OnError.REPORT: log(ex.getLocation() + "Warning: " + ex.getMessage(), Project.MSG_WARN); break; default: log(ex.getLocation() + ex.getMessage(), Project.MSG_DEBUG);
if (e.getLocation() == null && getLocation() != null) { e.setLocation(getLocation());
DispatchUtils.execute(this); } catch (BuildException ex) { if (ex.getLocation() == Location.UNKNOWN_LOCATION) { ex.setLocation(getLocation());
if ( buildException == null || buildException.getLocation() == null || buildException.getLocation().getFileName() == null ) File antFile = new File( buildException.getLocation().getFileName() ); if ( !antFile.exists() ) while ( ( line = reader.readLine() ) != null ) if ( reader.getLineNumber() == buildException.getLocation().getLineNumber() ) return "around Ant part ..." + line.trim() + "... @ " + buildException.getLocation().getLineNumber() + ":" + buildException.getLocation().getColumnNumber() + " in " + antFile.getAbsolutePath();
/** * Wraps a Ant {@link BuildException} to an {@link InstallerException}. * This is mainly done for the purpose of cutting of the location from the build failure message. * Locations should appear just in logs, not to the user. * * @param e the {@link IzPackException} with the nested {@link BuildException} * @throws InstallerException */ public void throwBuildException(IzPackException e) throws InstallerException { String message; Throwable cause = e.getCause(), nested = e; IzPackException ize = e; while (cause != null) { nested = cause; cause = cause.getCause(); } if (nested instanceof BuildException) { // Workaround for BuildException.toString(): // Filter off the location, just leave the clean failure message Location location = ((BuildException)nested).getLocation(); message = nested.toString().substring(location.toString().length()); ize = new IzPackException(message, e, severity); } throw new InstallerException(ize); }
if (ex.getLocation() == Location.UNKNOWN_LOCATION) { ex.setLocation(task.getLocation());
if (ex.getLocation() == Location.UNKNOWN_LOCATION) { ex.setLocation(task.getLocation());
+ " See log for details.", ex.getCause(), ex.getLocation());
+ " See log for details.", ex.getCause(), ex.getLocation());
if (e instanceof BuildException) { final BuildException be = (BuildException) e; if (be.getLocation() == null) { be.setLocation(getLocation());
+ " See Cargo log for details.", e.getCause(), e.getLocation());
markHierarchy(node, severity, e.getMessage()); Location location = e.getLocation(); int line = 0; int originalOffset = 0;