|  |  |  | 
|---|
|  |  |  | import org.springframework.security.core.userdetails.UsernameNotFoundException; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  | import org.springframework.web.bind.MethodArgumentNotValidException; | 
|---|
|  |  |  | import org.springframework.web.client.ResourceAccessException; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.net.ssl.SSLException; | 
|---|
|  |  |  | import javax.validation.ValidationException; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @AfterThrowing(pointcut = "exceptionCatch()", throwing = "ex") | 
|---|
|  |  |  | public void afterThrows(JoinPoint jp, Exception ex) throws Exception { | 
|---|
|  |  |  | if (ex instanceof GlobalException || ex instanceof MethodArgumentNotValidException || ex instanceof ValidationException || ex instanceof DuplicateKeyException || ex instanceof BadCredentialsException || ex instanceof UsernameNotFoundException || ex instanceof SSLException) { | 
|---|
|  |  |  | if (ex instanceof ResourceAccessException || ex instanceof GlobalException || ex instanceof MethodArgumentNotValidException || ex instanceof ValidationException || ex instanceof DuplicateKeyException || ex instanceof BadCredentialsException || ex instanceof UsernameNotFoundException || ex instanceof SSLException) { | 
|---|
|  |  |  | throw ex; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (EXCLUDE_EXCEPTION.contains(ex.getMessage())) { | 
|---|
|  |  |  | throw ex; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (profiles.equals("dev") || profiles.equals("test")) { | 
|---|
|  |  |  | throw ex; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | exceptionData.setSimpleMsg(ex.getMessage()); | 
|---|
|  |  |  | sysExceptionDetailDao.insert(exceptionData); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DingTalkUtils.sendMsg(profiles + "--" + ex.getMessage(), exStr.substring(0, 200), exceptionData.getId()); | 
|---|
|  |  |  | String msg = ""; | 
|---|
|  |  |  | if (exStr.length() > 200) { | 
|---|
|  |  |  | msg = exStr.substring(0, 200); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | msg = exStr; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | DingTalkUtils.sendMsg(profiles + "--" + ex.getMessage(), msg, exceptionData.getId()); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("exception aop"); | 
|---|
|  |  |  | log.error("exception aop", e); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|