org.hyphenType.exit
Annotation Type ExitStatusConstant


@Retention(value=RUNTIME)
@Target(value=FIELD)
public @interface ExitStatusConstant

A message to decorate the exit status constants for the final users.

Author:
akira

Required Element Summary
 String message
          Message to the end user of the application when a problem happens.
 String userDescription
          The description that will appear in the documentation for the end user.
 
Optional Element Summary
 Class<? extends Throwable>[] catches
          The list of throwable classes that will be caught by the exit status constant decorated by this annotation.
 

Element Detail

userDescription

public abstract String userDescription
The description that will appear in the documentation for the end user.


message

public abstract String message
Message to the end user of the application when a problem happens. The value of this variable may refer to replacements using the standard of Formatter.format(String, Object...). The values of replacement objects ({0}, {1}, etc.) depends on how the JVM or environment is going to exit:
  1. Explicit call to Options.exit(Enum, Object...) - The values of {0}, {1}, etc will be set to be the values of the array (second argument).
  2. Explicit call to Options#exit(int, Object...)) - Idem to the above.
  3. Explicit call to Options.exit(Throwable) - {0} will be set to be Throwable.getLocalizedMessage() and {1} will be the string printed by calling Throwable.printStackTrace().
  4. When this exit status constant catches an exception - Exit status constants may catch exceptions listed in the property catches(). When an exception is caught by an exit status constant, {0} and {1} will be treated as in the above: {0} will be set to be Throwable.getLocalizedMessage() and {1} will be the string printed by calling Throwable.printStackTrace()
In the two last cases, if Throwable.getLocalizedMessage() is null, it will be replaced by the empty string. This is to avoid the end user receiving a message such as: "Program terminated. Error message: null".

catches

public abstract Class<? extends Throwable>[] catches
The list of throwable classes that will be caught by the exit status constant decorated by this annotation. This list is used to implement a visitor design pattern that traps exceptions or errors from a main method. When an uncaught exception comes from a main class, hyphenType will search for one exit status constant that catches it. If an exit status constant catches the throwable, the method StatusCode.beforeExit(ExitStatusHelper) is called on this exit status constant and the throwable is accessible to the exit status constant via the method ExitStatusHelper.getThrowable().

It is important to notice that the NonExceptionalExit cannot be trapped by any exit status constant, since the NonExceptionalExit exception has a special meaning in hyphenType. For more details about the NonExceptionalExit exception, refer to the documentation of this class.

See Also:
NonExceptionalExit
Default:
{}


Copyright © 2013. All Rights Reserved.