package com.zhyc.module.feed.controller.Exception;

import com.zhyc.common.core.domain.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice
public class MaterialExceptionHandler {

    @ExceptionHandler({Exception.class, RuntimeException.class})
    public AjaxResult handleException(HttpServletRequest request, Exception ex) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.put("message", ex.getMessage());
        ajaxResult.put("url", request.getRequestURL().toString());
        ajaxResult.put("status", 500);
        ajaxResult.put("error", "出现了一些错误");
        return ajaxResult;
    }
}
