ÎļþÃû´Ó ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java ÐÞ¸Ä |
| | |
| | | package com.ruoyi.framework.web.exception; |
| | | package com.ruoyi.common.security.handler; |
| | | |
| | | import cn.dev33.satoken.exception.NotLoginException; |
| | | import cn.dev33.satoken.exception.NotPermissionException; |
| | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.exception.DemoModeException; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.StreamUtils; |
| | | import com.ruoyi.common.core.exception.DemoModeException; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.utils.StreamUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.mybatis.spring.MyBatisSystemException; |
| | | import org.springframework.context.support.DefaultMessageSourceResolvable; |
| | | import org.springframework.dao.DuplicateKeyException; |
| | | import org.springframework.validation.BindException; |
| | | import org.springframework.web.HttpRequestMethodNotSupportedException; |
| | | import org.springframework.web.bind.MethodArgumentNotValidException; |
| | |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',䏿¯æ'{}'请æ±", requestURI, e.getMethod()); |
| | | return R.fail(e.getMessage()); |
| | | } |
| | | |
| | | /** |
| | | * 䏻鮿UNIQUEç´¢å¼ï¼æ°æ®éå¤å¼å¸¸ |
| | | */ |
| | | @ExceptionHandler(DuplicateKeyException.class) |
| | | public R<Void> handleDuplicateKeyException(DuplicateKeyException e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | log.error("请æ±å°å'{}',æ°æ®åºä¸å·²åå¨è®°å½'{}'", requestURI, e.getMessage()); |
| | | return R.fail("æ°æ®åºä¸å·²åå¨è¯¥è®°å½ï¼è¯·è系管çå确认"); |
| | | } |
| | | |
| | | /** |
| | | * Mybatisç³»ç»å¼å¸¸ éç¨å¤ç |
| | | */ |
| | | @ExceptionHandler(MyBatisSystemException.class) |
| | | public R<Void> handleCannotFindDataSourceException(MyBatisSystemException e, HttpServletRequest request) { |
| | | String requestURI = request.getRequestURI(); |
| | | String message = e.getMessage(); |
| | | if (message.contains("CannotFindDataSourceException")) { |
| | | log.error("请æ±å°å'{}', æªæ¾å°æ°æ®æº", requestURI); |
| | | return R.fail("æªæ¾å°æ°æ®æºï¼è¯·è系管çå确认"); |
| | | } |
| | | log.error("请æ±å°å'{}', Mybatisç³»ç»å¼å¸¸", requestURI, e); |
| | | return R.fail(message); |
| | | } |
| | | |
| | | /** |