Example usage for java.lang RuntimeException printStackTrace

List of usage examples for java.lang RuntimeException printStackTrace

Introduction

In this page you can find the example usage for java.lang RuntimeException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.azyva.dragom.tool.ExecContextManagerTool.java

/**
 * Method main.//from w  ww  .j a  v a2s  .  c  o  m
 *
 * @param args Arguments.
 */
public static void main(String[] args) {
    DefaultParser defaultParser;
    CommandLine commandLine;
    String command;
    int exitStatus;

    ExecContextManagerTool.init();

    try {
        defaultParser = new DefaultParser();

        try {
            commandLine = defaultParser.parse(ExecContextManagerTool.options, args);
        } catch (org.apache.commons.cli.ParseException pe) {
            throw new RuntimeExceptionUserError(MessageFormat.format(
                    CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE),
                    pe.getMessage(), CliUtil.getHelpCommandLineOption()));
        }

        if (CliUtil.hasHelpOption(commandLine)) {
            ExecContextManagerTool.help();
        } else {
            args = commandLine.getArgs();

            if (args.length < 1) {
                throw new RuntimeExceptionUserError(MessageFormat.format(
                        CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_ARGUMENT_COUNT),
                        CliUtil.getHelpCommandLineOption()));
            }

            command = args[0];

            if (command.equals("force-unlock")) {
                ExecContextHolder.forceUnset(CliUtil.setupExecContext(commandLine, false));
            } else {
                CliUtil.setupExecContext(commandLine, true);

                if (command.equals("release")) {
                    ExecContextManagerTool.releaseCommand(commandLine);
                } else if (command.equals("get-properties")) {
                    ExecContextManagerTool.getPropertiesCommand(commandLine);
                } else if (command.equals("get-property")) {
                    ExecContextManagerTool.getPropertyCommand(commandLine);
                } else if (command.equals("set-property")) {
                    ExecContextManagerTool.setPropertyCommand(commandLine);
                } else if (command.equals("set-properties-from-tool-properties")) {
                    ExecContextManagerTool.setPropertiesFromToolPropertiesCommand(commandLine);
                } else if (command.equals("remove-property")) {
                    ExecContextManagerTool.removePropertyCommand(commandLine);
                } else if (command.equals("remove-properties")) {
                    ExecContextManagerTool.removePropertiesCommand(commandLine);
                } else if (command.equals("get-init-properties")) {
                    ExecContextManagerTool.getInitPropertiesCommand(commandLine);
                } else if (command.equals("get-init-property")) {
                    ExecContextManagerTool.getInitPropertyCommand(commandLine);
                } else {
                    throw new RuntimeExceptionUserError(MessageFormat.format(
                            CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_COMMAND), command,
                            CliUtil.getHelpCommandLineOption()));
                }
            }
        }

        // Need to call before ExecContextHolder.endToolAndUnset.
        exitStatus = Util.getExitStatusAndShowReason();
    } catch (RuntimeExceptionUserError reue) {
        System.err.println(
                CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_USER_ERROR_PREFIX) + reue.getMessage());
        exitStatus = 1;
    } catch (RuntimeException re) {
        re.printStackTrace();
        exitStatus = 1;
    } finally {
        ExecContextHolder.endToolAndUnset();
    }

    System.exit(exitStatus);
}

From source file:org.azyva.dragom.tool.CredentialManagerTool.java

/**
 * Method main./*  ww w.j  ava2 s .  c om*/
 *
 * @param args Arguments.
 */
public static void main(String[] args) {
    DefaultParser defaultParser;
    CommandLine commandLine;
    String command;
    int exitStatus;

    CredentialManagerTool.init();

    try {
        defaultParser = new DefaultParser();

        try {
            commandLine = defaultParser.parse(CredentialManagerTool.options, args);
        } catch (org.apache.commons.cli.ParseException pe) {
            throw new RuntimeExceptionUserError(MessageFormat.format(
                    CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE),
                    pe.getMessage(), CliUtil.getHelpCommandLineOption()));
        }

        if (CliUtil.hasHelpOption(commandLine)) {
            CredentialManagerTool.help();
        } else {
            args = commandLine.getArgs();

            if (args.length == 0) {
                throw new RuntimeExceptionUserError(MessageFormat.format(
                        CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_ARGUMENT_COUNT),
                        CliUtil.getHelpCommandLineOption()));
            }

            CliUtil.setupExecContext(commandLine, true);

            command = args[0];

            if (command.equals("enum-resource-realm-mappings")) {
                CredentialManagerTool.enumResourceRealmMappingsCommand(commandLine);
            } else if (command.equals("enum-passwords")) {
                CredentialManagerTool.enumPasswordsCommand(commandLine);
            } else if (command.equals("get-password")) {
                CredentialManagerTool.getPasswordCommand(commandLine);
            } else if (command.equals("set-password")) {
                CredentialManagerTool.setPasswordCommand(commandLine);
            } else if (command.equals("remove-password")) {
                CredentialManagerTool.removePasswordCommand(commandLine);
            } else if (command.equals("enum-default-users")) {
                CredentialManagerTool.enumDefaultUsersCommand(commandLine);
            } else if (command.equals("get-default-user")) {
                CredentialManagerTool.getDefaultUserCommand(commandLine);
            } else if (command.equals("set-default-user")) {
                CredentialManagerTool.setDefaultUserCommand(commandLine);
            } else if (command.equals("remove-default-user")) {
                CredentialManagerTool.removeDefaultUserCommand(commandLine);
            } else {
                throw new RuntimeExceptionUserError(MessageFormat.format(
                        CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_COMMAND), command,
                        CliUtil.getHelpCommandLineOption()));
            }
        }

        // Need to call before ExecContextHolder.endToolAndUnset.
        exitStatus = Util.getExitStatusAndShowReason();
    } catch (RuntimeExceptionUserError reue) {
        System.err.println(
                CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_USER_ERROR_PREFIX) + reue.getMessage());
        exitStatus = 1;
    } catch (RuntimeException re) {
        re.printStackTrace();
        exitStatus = 1;
    } finally {
        ExecContextHolder.endToolAndUnset();
    }

    System.exit(exitStatus);
}

From source file:org.azyva.dragom.tool.RootManagerTool.java

/**
 * Method main.//  w ww  .  j  a v a  2s  .  c o m
 *
 * @param args Arguments.
 */
public static void main(String[] args) {
    DefaultParser defaultParser;
    CommandLine commandLine;
    String command;
    int exitStatus;

    RootManagerTool.init();

    try {
        defaultParser = new DefaultParser();

        try {
            commandLine = defaultParser.parse(RootManagerTool.options, args);
        } catch (org.apache.commons.cli.ParseException pe) {
            throw new RuntimeExceptionUserError(MessageFormat.format(
                    CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE),
                    pe.getMessage(), CliUtil.getHelpCommandLineOption()));
        }

        if (CliUtil.hasHelpOption(commandLine)) {
            RootManagerTool.help();
        } else {
            args = commandLine.getArgs();

            if (args.length < 1) {
                throw new RuntimeExceptionUserError(MessageFormat.format(
                        CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_ARGUMENT_COUNT),
                        CliUtil.getHelpCommandLineOption()));
            }

            CliUtil.setupExecContext(commandLine, true);

            command = args[0];

            if (command.equals("list")) {
                RootManagerTool.listCommand(commandLine);
            } else if (command.equals("add")) {
                RootManagerTool.addCommand(commandLine);
            } else if (command.equals("add-from-file")) {
                RootManagerTool.addFromFileCommand(commandLine);
            } else if (command.equals("add-artifact")) {
                RootManagerTool.addArtifactCommand(commandLine);
            } else if (command.equals("add-artifact-from-file")) {
                RootManagerTool.addArtifactFromFileCommand(commandLine);
            } else if (command.equals("remove")) {
                RootManagerTool.removeCommand(commandLine);
            } else if (command.equals("remove-all")) {
                RootManagerTool.removeAllCommand(commandLine);
            } else if (command.equals("list-reference-path-matchers")) {
                RootManagerTool.listReferencePathMatchersCommand(commandLine);
            } else if (command.equals("add-reference-path-matcher")) {
                RootManagerTool.addReferencePathMatcherCommand(commandLine);
            } else if (command.equals("remove-reference-path-matcher")) {
                RootManagerTool.removeReferencePathMatcherCommand(commandLine);
            } else if (command.equals("remove-all-reference-path-matchers")) {
                RootManagerTool.removeAllReferencePathMatchersCommand(commandLine);
            } else {
                throw new RuntimeExceptionUserError(MessageFormat.format(
                        CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_COMMAND), command,
                        CliUtil.getHelpCommandLineOption()));
            }
        }

        // Need to call before ExecContextHolder.endToolAndUnset.
        exitStatus = Util.getExitStatusAndShowReason();
    } catch (RuntimeExceptionUserError reue) {
        System.err.println(
                CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_USER_ERROR_PREFIX) + reue.getMessage());
        exitStatus = 1;
    } catch (RuntimeException re) {
        re.printStackTrace();
        exitStatus = 1;
    } finally {
        ExecContextHolder.endToolAndUnset();
    }

    System.exit(exitStatus);
}

From source file:org.azyva.dragom.tool.WorkspaceManagerTool.java

/**
 * Method main.// w ww .j  a v  a2 s.  c  om
 *
 * @param args Arguments.
 */
public static void main(String[] args) {
    DefaultParser defaultParser;
    CommandLine commandLine;
    String command;
    int exitStatus;

    WorkspaceManagerTool.init();

    try {
        defaultParser = new DefaultParser();

        try {
            commandLine = defaultParser.parse(WorkspaceManagerTool.options, args);
        } catch (org.apache.commons.cli.ParseException pe) {
            throw new RuntimeExceptionUserError(MessageFormat.format(
                    CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_ERROR_PARSING_COMMAND_LINE),
                    pe.getMessage(), CliUtil.getHelpCommandLineOption()));
        }

        if (CliUtil.hasHelpOption(commandLine)) {
            WorkspaceManagerTool.help();
        } else {
            WorkspaceManagerTool workspaceManagerTool;

            args = commandLine.getArgs();

            if (args.length < 1) {
                throw new RuntimeExceptionUserError(MessageFormat.format(
                        CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_ARGUMENT_COUNT),
                        CliUtil.getHelpCommandLineOption()));
            }

            command = args[0];

            workspaceManagerTool = new WorkspaceManagerTool();

            workspaceManagerTool.commandLine = commandLine;
            workspaceManagerTool.execContext = CliUtil.setupExecContext(commandLine, true);
            workspaceManagerTool.workspacePlugin = workspaceManagerTool.execContext
                    .getExecContextPlugin(WorkspacePlugin.class);
            workspaceManagerTool.userInteractionCallbackPlugin = ExecContextHolder.get()
                    .getExecContextPlugin(UserInteractionCallbackPlugin.class);
            workspaceManagerTool.model = ExecContextHolder.get().getModel();

            if (command.equals("status")) {
                workspaceManagerTool.statusCommand();
            } else if (command.equals("update")) {
                workspaceManagerTool.updateCommand();
            } else if (command.equals("commit")) {
                workspaceManagerTool.commitCommand();
            } else if (command.equals("clean-all")) {
                workspaceManagerTool.cleanAllCommand();
            } else if (command.equals("clean-system")) {
                workspaceManagerTool.cleanSystemCommand();
            } else if (command.equals("clean-user")) {
                workspaceManagerTool.cleanUserCommand();
            } else if (command.equals("clean-non-root-reachable")) {
                workspaceManagerTool.cleanNonRootReachableCommand();
            } else if (command.equals("remove-module-version")) {
                workspaceManagerTool.removeModuleVersionCommand();
            } else if (command.equals("remove-dir")) {
                workspaceManagerTool.removeDirCommand();
            } else if (command.equals("build-clean-all")) {
                workspaceManagerTool.buildCleanAllCommand();
            } else if (command.equals("build-clean-module-version")) {
                workspaceManagerTool.buildCleanModuleVersionCommand();
            } else if (command.equals("build-clean-dir")) {
                workspaceManagerTool.buildCleanDirCommand();
            } else if (command.equals("fix")) {
                workspaceManagerTool.fixCommand();
            } else {
                throw new RuntimeExceptionUserError(MessageFormat.format(
                        CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_INVALID_COMMAND), command,
                        CliUtil.getHelpCommandLineOption()));
            }
        }

        // Need to call before ExecContextHolder.endToolAndUnset.
        exitStatus = Util.getExitStatusAndShowReason();
    } catch (RuntimeExceptionUserError reue) {
        System.err.println(
                CliUtil.getLocalizedMsgPattern(CliUtil.MSG_PATTERN_KEY_USER_ERROR_PREFIX) + reue.getMessage());
        exitStatus = 1;
    } catch (RuntimeException re) {
        re.printStackTrace();
        exitStatus = 1;
    } finally {
        ExecContextHolder.endToolAndUnset();
    }

    System.exit(exitStatus);
}

From source file:gov.nasa.ensemble.dictionary.nddl.ParseInterpreter.java

public static void main(String[] args) throws Exception {
    try {//from w  w  w . j  a v  a2 s .  c  om
        CommandLineArguments cmd = new CommandLineArguments(args);

        // Create a resource set to hold the resources.
        //
        ResourceSet resourceSet = new ResourceSetImpl();

        // Register the package to ensure it is available during loading.
        //
        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap()
                .put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
        resourceSet.getPackageRegistry().put(DictionaryPackage.eNS_URI, DictionaryPackage.eINSTANCE);

        // Construct the URI for the instance file.
        // The argument is treated as a file path only if it denotes an
        // existing file.
        // Otherwise, it's directly treated as a URL.
        //

        File file = new File(cmd.getValue(Option.ACTIVITY_DICTIONARY_FILE));
        URI uri = file.isFile() ? URI.createFileURI(file.getAbsolutePath())
                : URI.createURI(cmd.getValue(Option.ACTIVITY_DICTIONARY_FILE));

        try {
            // Demand load resource for this file.
            //
            Resource resource = resourceSet.getResource(uri, true);
            EActivityDictionary eActivityDictionary = (EActivityDictionary) resource.getContents().get(0);

            ParseInterpreter parseInterpreter = new ParseInterpreter(eActivityDictionary,
                    cmd.getValue(Option.CPU_STATE), cmd.getValue(Option.CPU_VALUE),
                    cmd.getIntValue(Option.BOOT), cmd.getIntValue(Option.SHUTDOWN),
                    cmd.getIntValue(Option.GAP));
            parseInterpreter.interpretAD(false);

            String path = cmd.getValue(Option.OUTPUT_DIRECTORY_PATH);
            path = path + uri.trimFileExtension().lastSegment();

            FileOutputStream objStream = new FileOutputStream(path + "-objects.nddl");
            FileOutputStream modelStream = new FileOutputStream(path + "-model.nddl");
            FileOutputStream initStateStream = new FileOutputStream(path + "-initial-state.nddl");
            objStream.flush();
            modelStream.flush();
            initStateStream.flush();

            parseInterpreter.writeObjects(objStream);
            objStream.close();
            parseInterpreter.writeCompats(modelStream, path + "-objects.nddl");
            modelStream.close();
            parseInterpreter.writeInitialState(initStateStream, path + "-model.nddl");

        } catch (RuntimeException exception) {
            System.out.println("Problem loading " + uri);
            exception.printStackTrace();
        }
    } catch (Exception e) {
        System.out.println(getManPageText());
    }
}

From source file:Main.java

public static void removeCustomProgressDialog() {
    try {//from ww  w. j  a  v  a2 s  .c  om
        if (mDialog != null) {
            mDialog.dismiss();
            mDialog = null;
        }
    } catch (IllegalArgumentException ie) {
        ie.printStackTrace();

    } catch (RuntimeException re) {
        re.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:Main.java

public static void removeSimpleProgressDialog() {
    try {//from   w  ww .  j  ava  2 s  . c  o m
        if (mProgressDialog != null) {
            if (mProgressDialog.isShowing()) {
                mProgressDialog.dismiss();
                mProgressDialog = null;
            }
        }
    } catch (IllegalArgumentException ie) {
        ie.printStackTrace();

    } catch (RuntimeException re) {
        re.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:Main.java

public static void removeCustomeProgressDialog() {
    try {/*w  w w  .j  a  va  2s  .  c om*/
        if (mDialog != null) {
            if (mDialog.isShowing()) {
                mDialog.dismiss();
                mDialog = null;
            }
        }
    } catch (IllegalArgumentException ie) {
        ie.printStackTrace();

    } catch (RuntimeException re) {
        re.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:Main.java

public static void showSimpleProgressDialog(Context context, String title, String msg, boolean isCancelable) {
    try {//w  ww  .  j av  a2  s  . c o m
        if (mProgressDialog == null) {
            mProgressDialog = ProgressDialog.show(context, title, msg);
            mProgressDialog.setCancelable(isCancelable);
        }
        if (!mProgressDialog.isShowing()) {
            mProgressDialog.show();
        }

    } catch (IllegalArgumentException ie) {
        ie.printStackTrace();
    } catch (RuntimeException re) {
        re.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:Main.java

public static void showSimpleProgressDialog(Context context, String title, String msg, boolean isCancelable) {
    try {/*w  ww.  ja va2  s  . com*/
        if (mProgressDialog == null) {
            mProgressDialog = ProgressDialog.show(context, title, msg);
            mProgressDialog.setCancelable(isCancelable);
        }

        if (!mProgressDialog.isShowing()) {
            mProgressDialog.show();
        }

    } catch (IllegalArgumentException ie) {
        ie.printStackTrace();
    } catch (RuntimeException re) {
        re.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}