generalfailureexception.java

来自「一个优秀的供应商管理系统」· Java 代码 · 共 50 行

JAVA
50
字号
package apusic.myshop.control;import java.rmi.RemoteException;import javax.naming.NamingException;import javax.ejb.CreateException;import javax.ejb.EJBException;import java.sql.SQLException;/*** This exception is thrown for all problems that occur in the EJB* Container code of the sample application. This class defines a few* typical error types to help the developer find the error* cause.*/public class GeneralFailureException extends EJBException    implements java.io.Serializable {    private String cause;    public static final String COMM_FAILURE = "RMI/IIOP problem";    public static final String EJB_CREATION_FAILURE = "EJB creation problem";    public static final String JNDI_PROBLEMS = "JNDI problem";    public static final String DB_PROBLEMS = "Database problem";    public GeneralFailureException(String cause) {	    super(cause);	    this.cause = cause;    }    public GeneralFailureException(Exception e) {	    super(e);	    if (e instanceof NamingException) {	        this.cause = JNDI_PROBLEMS;	    } else if (e instanceof SQLException) {	        this.cause = DB_PROBLEMS;	    } else if (e instanceof CreateException) {	        this.cause = EJB_CREATION_FAILURE;	    } else if (e instanceof RemoteException) {	        this.cause = COMM_FAILURE;	    } else {            this.cause = e.toString();      }    }    public String getCause() {	    return cause;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?