Custom error throwing "Unhandled Exception Type" when called

What am I doing wrong?

Here is my code:

void setup() {
  size(100, 100);

  throw new customException("test");
}

class customException extends Exception{
    
  customException(String message){
    super(message);
  }
}
1 Like
void setup() {
  try {
    throw new CustomException("test");
  } 
  catch (final CustomException ex) {
    ex.printStackTrace();
    exit();
  }
}

class CustomException extends Exception {
  CustomException(final String msg) {
    super(msg);
  }
}
1 Like