|
@@ -9,6 +9,7 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
|
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
|
|
|
|
+import javax.mail.MessagingException;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.Objects;
|
|
|
|
|
@@ -64,10 +65,19 @@ public class UnifiedExceptionHandler {
|
|
|
/**
|
|
|
* 其他未知异常
|
|
|
*/
|
|
|
+ @ExceptionHandler(value = MessagingException.class)
|
|
|
+ public R handleException(MessagingException e) {
|
|
|
+ log.error(request.getRequestURI(), e);
|
|
|
+ return R.error(HttpStatus.HTTP_INTERNAL_ERROR, "邮件相关异常,异常信息:" + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 其他未知异常
|
|
|
+ */
|
|
|
@ExceptionHandler(value = Exception.class)
|
|
|
public R handleException(Exception e) {
|
|
|
log.error(request.getRequestURI(), e);
|
|
|
- return R.error(HttpStatus.HTTP_INTERNAL_ERROR, "系统出现未知异常,请联系管理员");
|
|
|
+ return R.error(HttpStatus.HTTP_INTERNAL_ERROR, "邮件服务出现未知异常,请联系管理员");
|
|
|
}
|
|
|
|
|
|
}
|