package com.elephant.framework.galaxy.aroad.exception;

/**
 * @Description 全局异常类实现(包装器模式)
 * @auther wangjian
 * @create 2019-02-18 15:56
 */
public class GlobalException extends Exception implements CommonError {

    private CommonError commonError;

    public GlobalException(CommonError commonError) {
        super();
        this.commonError = commonError;
    }

    public GlobalException(CommonError commonError, String errorMessage) {
        super();
        this.commonError = commonError;
        this.commonError.setErrorMessage(errorMessage);
    }


    @Override
    public int getErrorCode() {
        return this.commonError.getErrorCode();
    }

    @Override
    public String getErrorMessage() {
        return this.commonError.getErrorMessage();
    }

    @Override
    public CommonError setErrorMessage(String errorMessage) {
        this.commonError.setErrorMessage(errorMessage);
        return this;
    }
}
