package com.chushang.common.core.exception;

import com.chushang.common.core.exception.enums.ExceptionEnum;
import com.chushang.common.core.web.EnumUtils;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serial;

@Setter
@Getter
@NoArgsConstructor
public class ResultException extends RuntimeException {
	@Serial
	private static final long serialVersionUID = 1L;
	
    private String msg;
    private Integer code = 500;
	private String detailMsg;
    
    public ResultException(String msg) {
		super(msg);
		this.msg = msg;
	}
	
	public ResultException(String msg, Throwable e) {
		super(msg, e);
		this.msg = msg;
	}
	
	public ResultException(String msg, Integer code) {
		super(msg);
		this.msg = msg;
		this.code = code;
	}

	/**
	 * 内部 展示, 应当仅用于 调试 todo 怎么做没想好
	 */
	public ResultException(String msg,String detailMsg, Integer code) {
		super(msg);
		this.msg = msg;
		this.detailMsg = detailMsg;
		this.code = code;
	}

	public ResultException(EnumUtils.CodeEnum<String> codeEnum){
		super(codeEnum.getMsg());
		this.msg = codeEnum.getMsg();
		this.code = codeEnum.getCode();
	}

	public ResultException(String msg, Integer code, Throwable e) {
		super(msg, e);
		this.msg = msg;
		this.code = code;
	}


}