Search in sources :

Example 1 with NoSuchToolException

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;
}
Also used : ModelException(org.eclipse.ceylon.common.tool.ModelException) OptionArgumentException(org.eclipse.ceylon.common.tool.OptionArgumentException) NoSuchToolException(org.eclipse.ceylon.common.tool.NoSuchToolException) ToolError(org.eclipse.ceylon.common.tool.ToolError) FatalToolError(org.eclipse.ceylon.common.tool.FatalToolError) FatalToolError(org.eclipse.ceylon.common.tool.FatalToolError)

Example 2 with NoSuchToolException

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;
}
Also used : AnnotatedToolModel(org.eclipse.ceylon.common.tool.AnnotatedToolModel) NoSuchToolException(org.eclipse.ceylon.common.tool.NoSuchToolException) Tool(org.eclipse.ceylon.common.tool.Tool) CeylonBaseTool(org.eclipse.ceylon.common.tool.CeylonBaseTool)

Aggregations

NoSuchToolException (org.eclipse.ceylon.common.tool.NoSuchToolException)2 AnnotatedToolModel (org.eclipse.ceylon.common.tool.AnnotatedToolModel)1 CeylonBaseTool (org.eclipse.ceylon.common.tool.CeylonBaseTool)1 FatalToolError (org.eclipse.ceylon.common.tool.FatalToolError)1 ModelException (org.eclipse.ceylon.common.tool.ModelException)1 OptionArgumentException (org.eclipse.ceylon.common.tool.OptionArgumentException)1 Tool (org.eclipse.ceylon.common.tool.Tool)1 ToolError (org.eclipse.ceylon.common.tool.ToolError)1