123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package cn.com.qmth.ac.bean;
- /**
- * 有状态标识的运行时异常,在API层按500状态码处理
- */
- public class StatusException extends RuntimeException implements CodeNameException {
- private static final long serialVersionUID = -2411329525159341065L;
- private Integer code;
- private String name;
- /**
- * 有明确的文字提示
- *
- * @param message
- */
- public StatusException(String message) {
- super(message);
- }
- /**
- * 有明确的文字提示与触发来源
- *
- * @param message
- * @param cause
- */
- public StatusException(String message, Throwable cause) {
- super(message, cause);
- }
- /**
- * 带所有参数的构造方法
- *
- * @param code
- * - 数字标识,范围在100~999
- * @param name
- * - 异常详细类型
- * @param message
- * - 文字提示
- * @param cause
- * - 触发来源
- */
- public StatusException(Integer code, String name, String message, Throwable cause) {
- super(message, cause);
- if (code != null) {
- if (code < 100 || code > 999) {
- throw new IllegalArgumentException("StatusException.code should between 100~999");
- }
- }
- this.code = code;
- this.name = name;
- }
- public Integer getCode() {
- return code;
- }
- public String getName() {
- return name;
- }
- }
|