package com.cf.imes.module.report.framework.web.core.handler;

import com.bstek.ureport.exception.ReportException;
import com.cf.imes.framework.common.exception.enums.GlobalErrorCodeConstants;
import com.cf.imes.framework.common.pojo.CommonResult;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 自定义报表异常处理器
 *
 * @author Gqr
 * @since 2024/9/2 14:52
 */
@RestControllerAdvice
@AllArgsConstructor
@Slf4j
public class ReportExceptionHandler {

    @ExceptionHandler(value = ReportException.class)
    public CommonResult reportExceptionHandler(ReportException ex) {
        log.warn("[reportExceptionHandler]", ex);
        return CommonResult.error(GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR.getCode(), String.format("报表异常:%s", ex.getMessage()));
    }
}
