TaxAgentServiceException.java 1.72 KB
package com.diligrp.tax.central.exception;


import com.diligrp.tax.central.type.TaxSystemType;
import lombok.Getter;

/**
 * 所有模块异常类的基类
 */
@Getter
public class TaxAgentServiceException extends RuntimeException {
    /**
     * 错误码
     */
    private int code;

    /**
     * 是否打印异常栈
     */
    private boolean stackTrace;

    public TaxAgentServiceException() {

    }

    public TaxAgentServiceException(String message) {
        super(message);
        this.code = TaxSystemType.UNKNOWN_ERROR.code;
        this.stackTrace = true;
    }

    public TaxAgentServiceException(TaxSystemType systemType) {
        super(systemType.message);
        this.code = systemType.code;
        this.stackTrace = true;
    }

    public TaxAgentServiceException(TaxSystemType systemType, Throwable ex) {
        super(systemType.message, ex);
        this.code = systemType.code;
        this.stackTrace = true;
    }

    public TaxAgentServiceException(TaxSystemType systemType, String message) {
        super(message);
        this.code = systemType.code;
        this.stackTrace = true;
    }

    public TaxAgentServiceException(int code, String message) {
        super(message);
        this.code = code;
        this.stackTrace = true;
    }

    public TaxAgentServiceException(int code, String message, boolean stackTrace) {
        super(message);
        this.code = code;
        this.stackTrace = stackTrace;
    }

    public TaxAgentServiceException(int code, String message, Throwable ex) {
        super(message, ex);
        this.code = code;
        this.stackTrace = true;
    }

    @Override
    public Throwable fillInStackTrace() {
        return stackTrace ? super.fillInStackTrace() : this;
    }

}