12345678910111213141516171819 |
- package com.example.zijincao.exception;
-
- import com.example.zijincao.common.ResponseBean;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.web.bind.annotation.ExceptionHandler;
- import org.springframework.web.bind.annotation.ResponseBody;
- import org.springframework.web.bind.annotation.RestControllerAdvice;
-
- @Slf4j
- @RestControllerAdvice
- public class GlobalExceptionHandler {
-
- @ResponseBody
- @ExceptionHandler(Exception.class)
- public ResponseBean handleException(Exception e){
- log.error(e.getMessage(),e);
- return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
- }
- }
|