List of usage examples for java.util MissingResourceException printStackTrace
public void printStackTrace(PrintStream s)
From source file:name.livitski.databag.cli.Syntax.java
/** * Diagnostic entry point for the build process to check that all * usage strings that describe the application's syntax are present * in <code>usage.resources</code>. * Absent resources cause a <code>System.err</code> message * and a non-zero exit code./* w ww .ja v a2 s .co m*/ * @param args this method ignores its argument */ @SuppressWarnings("unchecked") public static void main(String[] args) { PrintStream out = System.err; Resources resources = new Resources(); final Class<Syntax> clazz = Syntax.class; String id = null; String legend = null; for (Option option : (Collection<Option>) OPTIONS.getOptions()) { try { id = getOptionId(option); legend = resources.getString(USAGE_BUNDLE, clazz, id).trim(); if (legend.indexOf('.') < legend.length() - 1) { out.printf( "Description of option %s must be a single sentence ending with a period. Got:%n\"%s\"%n", id, legend); System.exit(5); } if (option.hasArg()) resources.getString(USAGE_BUNDLE, clazz, "arg" + id); legend = null; } catch (MissingResourceException missing) { if (null == legend) { out.printf("Option \"%s\" does not have a description string in the resource bundle \"%s\"%n", id, USAGE_BUNDLE); missing.printStackTrace(out); System.exit(1); } out.printf("Required argument spec \"%s\" is missing from the resource bundle \"%s\"%n", getArgumentId(option), USAGE_BUNDLE); missing.printStackTrace(out); System.exit(2); } catch (Exception problem) { out.printf("Error while verifying option \"%s\" in the resource bundle \"%s\"%n", id, USAGE_BUNDLE); problem.printStackTrace(out); System.exit(-1); } } }