Using RaiderException - rsanchez-wsu/RaiderPlanner GitHub Wiki

RaiderException Implementation

When deciding when to implement the custom RaiderException, a thorough assessment of each class is necessary. For example, in the Main Controller, there are many instances of IOException, FileNotFoundException, and the general Exception being caught. RaiderException aims to log exceptions that occur more frequently in the application that way a more detailed error message can be delivered to the user and the developers.

The criteria for implementing RaiderException should be as follows:

  • Multiple occurrences of the same exception being caught
  • Caught exception is for an error that can occur frequently during operation
  • Too specific for users to understand

Example

Eclipse allows for automatic catch statement completion. There are multiple lines in MainController.java that use the auto-generated catch blocks to catch generic exceptions:

catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

For MainController.java, it would be useful to replace the generic Exceptions with RaiderException because nearly all catch blocks have a general Exception being caught.

When the generic exception is caught, that means that any exception can be caught in that statement and the developers may want to handle different exceptions differently. This makes it easier to replace exceptions with RaiderException because instead of throwing a general exception that provides no information to the user, RaiderException can log the error and provide a more useful message to its users and developers.