📄 libraryexception.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -