package com.imdroid.beidou;

import com.imdroid.beidou.common.HttpResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {


    @ExceptionHandler(Exception.class)
    @ResponseBody
    public HttpResult handleException(Exception e) {
        log.error("全局捕获异常：", e);
        return HttpResult.fail(e.getMessage());
    }

}
