我正在为Employee Service类实现自定义Exception。现在想要Exception类变量的getter函数。
package com.sentienz.service.exception;
public class EmployeeServiceCustomException extends Exception {
private final int code;
private final String genericmessage;
public EmployeeServiceCustomException(int code, String genericmessage) {
super();
this.code = code;
this.genericmessage = genericmessage;
}
public EmployeeServiceCustomException(String message, Throwable cause, int code, String genericmessage) {
super(message, cause);
this.code = code;
this.genericmessage = genericmessage;
}
public EmployeeServiceCustomException(String message, int code, String genericmessage) {
super(message);
this.code = code;
this.genericmessage = genericmessage;
}
public EmployeeServiceCustomException(Throwable cause, int code, String genericmessage) {
super(cause);
this.code = code;
this.genericmessage = genericmessage;
}
public int getCode() {
return this.code;
}
public String getGenericmessage() {
return this.genericmessage;
}
}
实际上,我想要这个,但我无法做到这一点。是java异常类有这个问题的所有私有变量或其他一些原因。
public int getMessage() {
return this.message;
}