package com.yihu.jw.base.util;

import com.yihu.jw.utils.AdminException;
import com.yihu.jw.utils.sfutils.MyErrorCode;
import org.csource.common.MyException;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;

//该类全局拦截Controller请求
@ControllerAdvice
public class ExceptionHandler {
    //对自定义RuntimeException进行拦截和相关响应的修改
    @org.springframework.web.bind.annotation.ExceptionHandler(AdminException.class)
    public ResponseEntity<ExceptionResult> handlerException(AdminException e) {
        MyErrorCode ee = e.getMyErrorCode();
        return ResponseEntity.status(ee.getCode()).body(new ExceptionResult(ee));
    }}
