#4 #5 Update exception of script command

Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
Emmanuel Bigeon 2019-06-08 10:55:35 -04:00
parent 3960b10e8e
commit 9cf30ef7d2

View File

@ -139,7 +139,7 @@ public final class ScriptExecution extends Command {
try (InputStreamReader fReader = new InputStreamReader(
Files.newInputStream(Paths.get(scriptFile)), charset);
BufferedReader reader = new BufferedReader(fReader)) {
String[] emptyArray = new String[0];
final String[] emptyArray = new String[0];
while ((cmd = reader.readLine()) != null) {
lineNo++;
final String cmdLine = readCommandLine(cmd, params);
@ -237,10 +237,16 @@ public final class ScriptExecution extends Command {
* @return the exception to actually throw */
private static CommandRunException manageRunException(final CommandRunException e,
final int lineNo) {
final StringBuilder builder = new StringBuilder(e.getLocalizedMessage());
int index = builder.indexOf("\n");
while (index > 0) {
builder.insert(index + 1, " ");
index = builder.indexOf("\n", index + 1);
}
return new CommandRunException(CommandRunExceptionType.EXECUTION,
MessageFormat.format(
"The script could not complete due to command failure at line {0} ({1})", //$NON-NLS-1$
Integer.valueOf(lineNo), e.getLocalizedMessage()),
"The script could not complete due to command failure at line {0}\n {1})", //$NON-NLS-1$
Integer.valueOf(lineNo + 1), builder.toString()),
e);
}