| | |
| | | |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResultMessage; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.web.bind.annotation.ControllerAdvice; |
| | | import org.springframework.web.bind.annotation.ExceptionHandler; |
| | |
| | | |
| | | @ControllerAdvice |
| | | @ResponseBody |
| | | @Slf4j |
| | | public class GlobalExceptionHandler { |
| | | /** |
| | | * 处理全部异常 |
| | |
| | | @ResponseBody |
| | | @ResponseStatus(HttpStatus.OK) |
| | | public ResultMessage handleException(Exception ex) { |
| | | log.error(ex.getMessage()); |
| | | log.error(ex.getStackTrace().toString()); |
| | | return ResultMessage.fail(Constants.CODE_OPERATION_FAILED, "请求失败"); |
| | | } |
| | | |