瀏覽代碼

异常处理

Progr1mmer 6 年之前
父節點
當前提交
85d2029751
共有 1 個文件被更改,包括 3 次插入7 次删除
  1. 3 7
      common/common-web/src/main/java/com/yihu/jw/web/exception/ApiException.java

+ 3 - 7
common/common-web/src/main/java/com/yihu/jw/web/exception/ApiException.java

@ -1,6 +1,8 @@
package com.yihu.jw.web.exception;
import org.springframework.util.Assert;
public class ApiException extends RuntimeException {
    private String errorDesc; //错误消息
@ -12,6 +14,7 @@ public class ApiException extends RuntimeException {
    public ApiException(String errorDesc, int errorCode) {
        super(errorDesc);
        Assert.state(errorCode != 200, "The error code cannot be equal to 200");
        this.errorDesc = errorDesc;
        this.errorCode = errorCode;
    }
@ -20,15 +23,8 @@ public class ApiException extends RuntimeException {
        return errorDesc;
    }
    public void setErrorDesc(String errorDesc) {
        this.errorDesc = errorDesc;
    }
    public int getErrorCode() {
        return errorCode;
    }
    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }
}