In case, there is no default exception you could use. Make one yourself.

The functions already exists in the built-in Exception class, the only thing to do: is to add a personalised exception

super("personalised exception");

to use this function you also extend the class you are working in:

class MyException extends Exception {
}

Because the “super” function has to be placed first in a constructor, you can’t add the “super” statement to a random method.

There are two ways, to solve this problem:

  1. add a new class
  2. add a parametrised constructor