use of org.eclipse.ceylon.common.tool.NoSuchToolException in project ceylon by eclipse.
the class CeylonTool method handleException.
public static int handleException(CeylonTool mainTool, Exception ex) throws Exception {
int result;
if (ex instanceof NoSuchToolException) {
result = SC_NO_SUCH_TOOL;
} else if (ex instanceof ModelException) {
result = SC_TOOL_CREATION;
} else if (ex instanceof OptionArgumentException) {
result = SC_ARGS;
} else if (ex instanceof FatalToolError) {
result = SC_TOOL_BUG;
} else if (ex instanceof ToolError) {
ToolError err = (ToolError) ex;
result = err.isExitCodeProvided() ? err.getExitCode() : SC_TOOL_ERROR;
} else {
result = SC_TOOL_EXCEPTION;
}
Usage.handleException(mainTool, mainTool.getToolName(), ex);
return result;
}
use of org.eclipse.ceylon.common.tool.NoSuchToolException in project ceylon by eclipse.
the class CeylonTool method getTool.
public Tool getTool(ToolModel<?> model) {
Tool tool = null;
if (model == null) {
ArgumentModel<?> argumentModel = getToolModel("").getArguments().get(0);
// XXX Very evil hack to work around the fact that the CeyonTool does
// not use subtools yet, and so the model used to generate help doc
// doesn't quite work right.
argumentModel.setName("command");
throw new NoSuchToolException(argumentModel, getToolName());
}
if (!(model instanceof AnnotatedToolModel))
return null;
boolean useCache = false;
if (toolName != null && toolName.equals(model.getName()))
useCache = true;
if (useCache && toolCache != null)
return toolCache;
tool = getPluginFactory().bindArguments(model, this, toolArgs);
if (useCache)
toolCache = tool;
return tool;
}
Aggregations