PC ret;
try {
ret = invoker.invoke(this);
}
catch (org.crsh.cli.impl.SyntaxException e) {
throw new CommandException(ErrorKind.SYNTAX, "Syntax exception when executing command " + name, e);
} catch (InvocationException e) {
throw new CommandException(ErrorKind.EVALUATION, "Command " + name + " failed", e.getCause());
}
// It's a pipe command
if (ret != null) {
real = ret;
try {
real.open(invocationContext);
}
catch (Exception e) {
throw new CommandException(ErrorKind.EVALUATION, "Command " + name + " failed", e);
}
}
}
public void provide(C element) throws IOException, CommandException {
if (real != null) {
try {
real.provide(element);
}
catch (Exception e) {
throw new CommandException(ErrorKind.EVALUATION, "Command " + name + " failed", e);
}
}
}
public void flush() throws IOException {
if (real != null) {
real.flush();
} else {
invocationContext.flush();
}
}
public void close() throws IOException, CommandException {
try {
try {
if (real != null) {
real.close();
}
}
catch (Exception e) {
throw new CommandException(ErrorKind.EVALUATION, "Command " + name + " failed", e);
} finally {
try {
invocationContext.close();
}
catch (Exception e) {
throw new CommandException(ErrorKind.EVALUATION, e);
}
}
} finally {
command.popContext();
command.unmatched = null;