Application Exceptions

Here are some additional exceptions that extend the ForethoughtException class, which was defined in Chapter 5. Session beans and other components throughout the rest of the book use these exceptions.

Entity Exceptions

The exceptions in the following code listings are all used in reporting the specific problem associated with a specified entity (an office, user, account, and so forth) to session bean clients. Example E-37 is the exception for reporting that a fund being searched for cannot be located.

Example E-37. The FundNotFoundException Class

package com.forethought.ejb.fund;

import com.forethought.ForethoughtException;

public class FundNotFoundException extends ForethoughtException {

    /** The fund name that was not found */
    private String fundName;

    public FundNotFoundException(String fundName) {
        super("A fund with the name " + fundName +
            " could not be found.");
        this.fundName = fundName;
    }

    public String getFundName(  ) {
        return fundName;
    }
}

Example E-38 is the exception reported when an unknown user type is specified.

Example E-38. The UnknownUserTypeException Class

package com.forethought.ejb.userType; import com.forethought.ForethoughtException; public class UnknownUserTypeException extends ForethoughtException { /** The user type specified */ private String userType; public UnknownUserTypeException(String userType) { super("There is no user type called " + userType + " in the Forethought application."); this.userType = userType; } public String getUserType( ...

Get Building Java Enterprise Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.