List of usage examples for java.util MissingResourceException getKey
public String getKey()
From source file:net.lethargiclion.informaban.InformaBanCommandExecutor.java
@Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { try {/*ww w . j a v a 2 s . c o m*/ if (command.getName().equalsIgnoreCase("kick")) return commandKick(sender, args); if (command.getName().equalsIgnoreCase("rap")) return commandRap(sender, args); if (command.getName().equalsIgnoreCase("ban")) return commandBan(sender, args); if (command.getName().equalsIgnoreCase("ipban")) return commandIPBan(sender, args); if (command.getName().equalsIgnoreCase("unban")) return commandUnban(sender, args); } catch (java.util.MissingResourceException e) { sender.sendMessage(new String[] { "[InformaBan] An internal error occured. Please file a bug report.", String.format("[InformaBan] Error: No message defined for \"%s\".", e.getKey()) }); } return false; }
From source file:pl.kiminoboku.emorg.service.ServiceMessageUtil.java
/** * Returns human-friendly message for given service exception * @param exception exception/*from w w w . ja v a 2s .c om*/ * @param <T> exception type * @return human-friendly message for exception */ public static <T extends Exception> String getServiceMessage(T exception) { String message = exception.getMessage(); //if exception message is empty, return exception name if (StringUtils.isEmpty(message)) { return exception.getClass().getCanonicalName(); } try { //try to find appropriate message in message bundle return NbBundle.getMessage(ServiceMessageUtil.class, exception.getMessage()); } catch (MissingResourceException ex) { //if message bundle is not present, return message key indicating that message is not present return "???" + ex.getKey() + "???"; } }