package com.malk.guyuan.filter;

import com.malk.filter.CatchException;
import com.malk.server.common.McR;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 腾讯云 [通用拦截参考 CatchException]
 */
@Slf4j
@RestControllerAdvice(annotations = RestController.class)
public class CatchException_YXY extends CatchException {

    /**
     * 错误类抛出
     */
    @ExceptionHandler(TencentCloudSDKException.class)
    public McR TencentCloudSDKException(TencentCloudSDKException e) {
        log.error(e.getMessage(), e);  // 记录错误日志
        // prd, 统一中文提示 return McR.errorVendor(e.getMessage(), "tencent");
        return McR.errorVendor("发票识别异常!", "tencent");
    }
}
