libraryexception.java

来自「Hibernate (著译者: 陈天河等)项目开发宝典本书以Hibernate为」· Java 代码 · 共 81 行

JAVA
81
字号
package cn.hxex.library.exception;

/**
 * 异常类
 * 
 * @author galaxy
 *
 */
public class LibraryException extends Exception {
	static final String USERNAME_NOT_EXIST = "userBean_no_existing_username";

	static final String INCORRECT_PASSWORD = "userBean_incorrect_password";

	static final String CATEGORY_NAME_DUPLICATE = "categoryBean_duplicate_category_name";

	static final String CATEGORY_NOT_EXIST = "categoryBean_not_existing_category";

	static final String CATEGORY_EXIST_PRODUCT = "categoryBean_existing_product";

	static final String PRODUCT_NAME_DUPLICATE = "productBean_duplicate_product_name";

	static final String PRODUCT_NOT_EXIST = "productBean_not_existing_product";

	static final String RECORD_NOT_EXIST = "recordBean_not_existing_record";

	/**
	 * Constructor with error message.
	 * 
	 * @param msg
	 *            the error message associated with the exception
	 */
	public LibraryException(String msg) {
		super(msg);
	}

	/**
	 * Constructor with error message and root cause.
	 * 
	 * @param msg
	 *            the error message associated with the exception
	 * @param cause
	 *            the root cause of the exception
	 */
	public LibraryException(String msg, Throwable cause) {
		super(msg, cause);
	}

	public static LibraryException getDuplicateCategoryNameException() {
		return new LibraryException(CATEGORY_NAME_DUPLICATE);
	}

	public static LibraryException getCategoryNotExistException() {
		return new LibraryException(CATEGORY_NOT_EXIST);
	}

	public static LibraryException getCategoryExistProductException() {
		return new LibraryException(CATEGORY_EXIST_PRODUCT);
	}

	public static LibraryException getUsernameNotExistException() {
		return new LibraryException(USERNAME_NOT_EXIST);
	}

	public static LibraryException getIncorrectPasswordException() {
		return new LibraryException(INCORRECT_PASSWORD);
	}

	public static LibraryException getDuplicateProductNameException() {
		return new LibraryException(PRODUCT_NAME_DUPLICATE);
	}

	public static LibraryException getProductNotExistException() {
		return new LibraryException(PRODUCT_NOT_EXIST);
	}

	public static LibraryException getRecordNotExistException() {
		return new LibraryException(RECORD_NOT_EXIST);
	}

}

⌨️ 快捷键说明

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