Reporting in Command Line Applications

In a Java application, invoked from the command line, you should report, both the exception's messages, and its stack trace, as the command line application typically does not have a button for requesting the details of the stack trace. The destination for the exception reporting usually will be System.err.

If you specify the main method as

public static void main(final String[] i_args) throws Exception {...}

you will already have a centralized exception reporting, but the Java Runtime system will report only the stack trace without giving nice textual error messages.

In order to get the textual message chain, and the stack trace, you must write your main method as follows:

public static void main(final String[] i_args) {
    ... //check and report argument violations
    try{
        _doTheWork(i_args);
    }catch(final Exception e){
        multex.Msg.printReport(e);
    }
}

This will report to System.err the exception chain/tree messages using for localization the resource bundle MsgText in the current working directory, followed by the stack trace. If you want to use another resource bundle for localization, then use the variant

printReport(StringBuffer, Throwable, ResourceBundle)

instead, and print out the filled StringBuffer, afterwards.