Search in sources :

Example 1 with ModelException

use of org.eclipse.ceylon.common.tool.ModelException 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)

Aggregations

FatalToolError (org.eclipse.ceylon.common.tool.FatalToolError)1 ModelException (org.eclipse.ceylon.common.tool.ModelException)1 NoSuchToolException (org.eclipse.ceylon.common.tool.NoSuchToolException)1 OptionArgumentException (org.eclipse.ceylon.common.tool.OptionArgumentException)1 ToolError (org.eclipse.ceylon.common.tool.ToolError)1