up previous next contents
Next: throw Up: Exceptions Previous: Objectives   Contents

Creating exception types

  • Exceptions are objects.
  • Must extend the class Throwable or one of it's subclasses.
  • By convention new exception types extend Exception (a subclass of Throwable).
      public class BadPizzaException extends Exception
      {
         public String attrName;
         BadPizzaException(String name)
         {
            super( "BadPizzaException: " + name );
            attrName = name;
         }
      }
    


up previous next contents
Next: throw Up: Exceptions Previous: Objectives   Contents