Class CommandExceptionAdapter

java.lang.Object
revxrsal.commands.exception.CommandExceptionAdapter
All Implemented Interfaces:
CommandExceptionHandler
Direct Known Subclasses:
DefaultExceptionHandler

public abstract class CommandExceptionAdapter extends Object implements CommandExceptionHandler
An implementation of CommandExceptionHandler that inlines all exceptions into individual, overridable methods. This greatly simplifies the process of handling exceptions.

This class loosely uses reflections to find the appropriate handler method. To handle custom exceptions, extend this class and define a method that meets the following criteria:

  1. Method is public
  2. Method has 2 parameters, one is a CommandActor (or a subclass of it), and the other is your exception. The name of the method, and the order of parameters does not matter.

An example:

 
 public void onCustomException(CommandActor actor, CustomException e) {
     actor.error("Caught you!");
 }
 
 
If you have methods that meet the above criteria and want the reflection handler to ignore them, annotate them with CommandExceptionAdapter.Ignore.