The Exception Class QuickCarRentalException

The purpose of the exception class QuickCarRentalException is to supply the car rental application with all the application-specific exceptions. Each exception should be wrapped as a QuickCarRentalException, so that an exception that is appropriate for the car rental application is always delivered to the client.

QuickCarRentalException extends java.lang.Exception.

Prerequisites

The structure of the Java project Helperclasses is currently displayed in the Package Explorer.

Procedure

Creating QuickCarRentalException in the Java project.

...

       1.      In the Package Explorer, select the project node Helperclasses.

       2.      Form the context menu, choose New ® Other...

       3.      Select Java  (in the left pane), followed by Class (in the right pane). Choose Next.

       4.      In the New Java Class wizard that appears, assign the following values:

   

Source Folder

Helperclasses

Package

com.sap.engine.examples.util

Name

QuickCarRentalException

Modifiers

public

Superclass

java.lang.Exception

Inherited abstract methods

activated

       5.      Leave all the other suggested values unchanged and choose Finish.

The wizard creates the new file QuickCarRentalException.java and opens the Java Editor.

Adding the superclass constructors

       6.      In the Java Editor position the cursor anywhere in the source code and click the right mouse button.

       7.      Choose Source ® Add Constructors from Superclass from the context menu.

The following code is generated:

   /**

    *

    */

   public QuickCarRentalException() {

       super();

       // TODO Auto-generated constructor stub

   }

 

   /**

    * @param message

    */

   public QuickCarRentalException(String message) {

       super(message);

       // TODO Auto-generated constructor stub

   }

 

   /**

    * @param cause

    */

   public QuickCarRentalException(Throwable cause) {

       super(cause);

       // TODO Auto-generated constructor stub

   }

 

   /**

    * @param message

    * @param cause

    */

   public QuickCarRentalException(String message, Throwable cause) {

       super(message, cause);

       // TODO Auto-generated constructor stub

   }

       8.      Delete the generated   // TODO lines .

       9.      Save the contents of the editor by choosing the appropriate icon from the toolbar.

Result

You have created and completely implemented the auxiliary class QuickCarRentalException.

Next step:

Exporting the JAR file