Exception handling in commands

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2011-02-18 16:25:06 +00:00
parent eb206f49c1
commit 636c1ec83a
4 changed files with 47 additions and 8 deletions

View File

@@ -8,7 +8,6 @@ import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
@@ -74,7 +73,13 @@ public final class SimpleCommandMap implements CommandMap {
Command target = knownCommands.get(sentCommandLabel);
boolean isRegisteredCommand = (target != null);
if (isRegisteredCommand) {
target.execute(sender, sentCommandLabel, args);
try {
target.execute(sender, sentCommandLabel, args);
} catch (CommandException ex) {
throw ex;
} catch (Throwable ex) {
throw new CommandException("Unhandled exception executing '" + commandLine + "' in " + target, ex);
}
}
return isRegisteredCommand;
}