Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
73a081fd
Commit
73a081fd
authored
Nov 12, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加日志异常处理
parent
3c62483a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
5 deletions
+2
-5
GlobalExceptionHandler.java
...iaoqi/security/common/handler/GlobalExceptionHandler.java
+2
-3
MailServiceImpl.java
...hub/wxiaoqi/security/common/log/Impl/MailServiceImpl.java
+0
-2
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/handler/GlobalExceptionHandler.java
View file @
73a081fd
...
...
@@ -9,7 +9,6 @@ import com.github.wxiaoqi.security.common.log.Impl.MailServiceImpl;
import
com.github.wxiaoqi.security.common.msg.BaseResponse
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.ControllerAdvice
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
...
@@ -23,8 +22,7 @@ import javax.servlet.http.HttpServletResponse;
@ResponseBody
public
class
GlobalExceptionHandler
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
@Autowired
MailServiceImpl
mailService
;
@ExceptionHandler
(
ClientTokenException
.
class
)
public
BaseResponse
clientTokenExceptionHandler
(
HttpServletResponse
response
,
ClientTokenException
ex
)
{
response
.
setStatus
(
403
);
...
...
@@ -67,6 +65,7 @@ public class GlobalExceptionHandler {
public
void
sendEmail
(
Exception
ex
)
{
try
{
logger
.
info
(
"发送异常邮件,邮件内容:【服务器异常】: {}"
,
ex
.
getMessage
()
+
":"
+
ex
);
MailServiceImpl
mailService
=
new
MailServiceImpl
();
mailService
.
sendSimpleMail
(
"jiaoruizhen@126.com"
,
"服务器异常"
,
ex
.
getMessage
()
+
":"
+
ex
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"发送异常邮件失败,异常信息: {}"
,
e
);
...
...
ace-common/src/main/java/com/github/wxiaoqi/security/common/log/Impl/MailServiceImpl.java
View file @
73a081fd
...
...
@@ -5,9 +5,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.mail.SimpleMailMessage
;
import
org.springframework.mail.javamail.JavaMailSender
;
import
org.springframework.stereotype.Service
;
@Service
@Slf4j
public
class
MailServiceImpl
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment