package com.xdap.self_development.exception;

import com.definesys.mpaas.common.http.Response;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

// 自定义异常处理类
@RestControllerAdvice
@Order(-2)
public class MyGlobalExceptionHandler {
    @ExceptionHandler(CommonException.class)
    public Response handleMpaasBusinessException(CommonException e) {
        if (e.getData() != null) {
            return Response.error(e.getMessage()).setData(e.getData());
        } else {
            return Response.error(e.getMessage());
        }
    }
}
