package com.ruoyi.credit.exception;

/**
 * 银行选择相关异常类
 * 
 * @author ruoyi
 * @date 2025-12-24
 */
public class BankSelectionException extends RuntimeException {
    
    private static final long serialVersionUID = 1L;
    
    /** 错误代码 */
    private String errorCode;
    
    /** 错误类型 */
    private ErrorType errorType;
    
    /** 是否可重试 */
    private boolean retryable;
    
    /** 建议的解决方案 */
    private String suggestion;
    
    public enum ErrorType {
        BANK_INFO_MISSING("银行信息缺失"),
        BANK_SERVICE_UNAVAILABLE("银行服务不可用"),
        DATA_INCONSISTENCY("数据不一致"),
        NETWORK_ERROR("网络错误"),
        VALIDATION_ERROR("验证错误"),
        BUSINESS_ERROR("业务错误");
        
        private final String description;
        
        ErrorType(String description) {
            this.description = description;
        }
        
        public String getDescription() {
            return description;
        }
    }
    
    public BankSelectionException(String message) {
        super(message);
        this.errorType = ErrorType.BUSINESS_ERROR;
        this.retryable = false;
    }
    
    public BankSelectionException(String message, ErrorType errorType) {
        super(message);
        this.errorType = errorType;
        this.retryable = false;
    }
    
    public BankSelectionException(String message, ErrorType errorType, boolean retryable) {
        super(message);
        this.errorType = errorType;
        this.retryable = retryable;
    }
    
    public BankSelectionException(String message, ErrorType errorType, boolean retryable, String suggestion) {
        super(message);
        this.errorType = errorType;
        this.retryable = retryable;
        this.suggestion = suggestion;
    }
    
    public BankSelectionException(String message, Throwable cause, ErrorType errorType) {
        super(message, cause);
        this.errorType = errorType;
        this.retryable = false;
    }
    
    public BankSelectionException(String message, Throwable cause, ErrorType errorType, boolean retryable) {
        super(message, cause);
        this.errorType = errorType;
        this.retryable = retryable;
    }
    
    // Getters and setters
    public String getErrorCode() {
        return errorCode;
    }
    
    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }
    
    public ErrorType getErrorType() {
        return errorType;
    }
    
    public void setErrorType(ErrorType errorType) {
        this.errorType = errorType;
    }
    
    public boolean isRetryable() {
        return retryable;
    }
    
    public void setRetryable(boolean retryable) {
        this.retryable = retryable;
    }
    
    public String getSuggestion() {
        return suggestion;
    }
    
    public void setSuggestion(String suggestion) {
        this.suggestion = suggestion;
    }
}