Exception System
This page should show you the integrated exception-system in QuarterBukkit. It's for catching exceptions like when a command sender hasn't enough permissions to execute a command. The system sends an event to the handler which can print an error message, for example.
Handler
The exceptions are handled by exception listeners. Here's an example:
public class TestExceptionHandler implements Listener {
public TestExceptionHandler(Plugin plugin) {
Bukkit.getPluginManager().registerEvents(this, pathbreaking.getPlugin());
}
@EventHandler
public void internalException(InternalException exception) {
exception.getCause().printStackTrace();
}
}
This is only a very simple example how to use the listener system. You should catch every exception (if you use the component) and handle it.
Default Exceptions
Every exception extend the class GameException
. There are many possible exceptions, and we'll add more in every new component.
Those are all game exeptions QuarterBukkit currently provides by default (the ---
means that an exception extends the class above it):
Exception | Description |
---|---|
InternalException | Something which is very internal (like reflection operations) goes wrong. |
NoPermissionException | A CommandSender hasn't enough permissions to do something.
|
--- NoCommandPermissionException | A CommandSender hasn't enough permissions to execute a command.
|
NoCommandFoundException | A command wasn't found after a CommandSender typed it in.
|
--- NoDefaultCommandFoundException | The default command wasn't found after a CommandSender tried to use it.
|
InstallException | Something goes wrong while using the Updater (contains getCause() ).
|
Of course, you can add your own exceptions if you want to.