Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beyond-clouds
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
段启岩
beyond-clouds
Commits
b7cc6a28
Commit
b7cc6a28
authored
Feb 03, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/qiyanduan02-03'
# Conflicts: # src/main/resources/application-prod.yml
parents
ce68c2ff
7c69194c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
+18
-8
src/main/java/cn/meteor/beyondclouds/common/handler/GlobalExceptionHandler.java
+16
-6
src/main/resources/application-prod.yml
+2
-2
No files found.
src/main/java/cn/meteor/beyondclouds/common/handler/GlobalExceptionHandler.java
View file @
b7cc6a28
package
cn
.
meteor
.
beyondclouds
.
common
.
handler
;
package
cn
.
meteor
.
beyondclouds
.
common
.
handler
;
import
cn.meteor.beyondclouds.common.enums.ErrorCode
;
import
cn.meteor.beyondclouds.config.properties.BeyondCloudsProperties
;
import
cn.meteor.beyondclouds.config.properties.BeyondCloudsProperties
;
import
cn.meteor.beyondclouds.core.api.Response
;
import
cn.meteor.beyondclouds.core.api.Response
;
import
cn.meteor.beyondclouds.common.enums.ErrorCode
;
import
cn.meteor.beyondclouds.core.exception.ServiceException
;
import
cn.meteor.beyondclouds.core.exception.ServiceException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.HttpRequestMethodNotSupportedException
;
import
org.springframework.web.HttpRequestMethodNotSupportedException
;
...
@@ -10,6 +10,9 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
...
@@ -10,6 +10,9 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.PrintStream
;
/**
/**
* 全局异常捕获器,捕获在Controller层未处理异常
* 全局异常捕获器,捕获在Controller层未处理异常
...
@@ -27,9 +30,7 @@ public class GlobalExceptionHandler {
...
@@ -27,9 +30,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
value
=
Exception
.
class
)
@ExceptionHandler
(
value
=
Exception
.
class
)
public
Response
<
String
>
exceptionHandler
(
HttpServletRequest
request
,
Exception
e
)
{
public
Response
<
String
>
exceptionHandler
(
HttpServletRequest
request
,
Exception
e
)
{
boolean
debugMode
=
beyondCloudsProperties
.
getDebug
();
boolean
debugMode
=
beyondCloudsProperties
.
getDebug
();
if
(
debugMode
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
if
(
e
instanceof
ServiceException
)
{
if
(
e
instanceof
ServiceException
)
{
ServiceException
exception
=
(
ServiceException
)
e
;
ServiceException
exception
=
(
ServiceException
)
e
;
return
Response
.
error
(
exception
.
getErrorCode
(),
exception
.
getErrorMsg
());
return
Response
.
error
(
exception
.
getErrorCode
(),
exception
.
getErrorMsg
());
...
@@ -37,10 +38,18 @@ public class GlobalExceptionHandler {
...
@@ -37,10 +38,18 @@ public class GlobalExceptionHandler {
return
Response
.
error
(
ErrorCode
.
OPERATION_FAILED
.
code
(),
e
.
getMessage
());
return
Response
.
error
(
ErrorCode
.
OPERATION_FAILED
.
code
(),
e
.
getMessage
());
}
else
{
}
else
{
if
(
debugMode
)
{
if
(
debugMode
)
{
return
Response
.
error
(
ErrorCode
.
OPERATION_FAILED
.
code
(),
e
.
getMessage
());
ByteArrayOutputStream
byteBuff
=
new
ByteArrayOutputStream
();
e
.
printStackTrace
(
new
PrintStream
(
byteBuff
));
String
errTrace
=
byteBuff
.
toString
();
try
{
byteBuff
.
close
();
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
}
return
Response
.
error
(
ErrorCode
.
OPERATION_FAILED
.
code
(),
errTrace
);
}
else
{
}
else
{
return
Response
.
error
();
return
Response
.
error
();
}
}
}
}
}
}
}
}
\ No newline at end of file
src/main/resources/application-prod.yml
View file @
b7cc6a28
...
@@ -2,8 +2,8 @@ spring:
...
@@ -2,8 +2,8 @@ spring:
datasource
:
datasource
:
driver-class-name
:
com.mysql.cj.jdbc.Driver
driver-class-name
:
com.mysql.cj.jdbc.Driver
url
:
jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
url
:
jdbc:mysql://127.0.0.1:3306/beyond_clouds?useUnicode=true&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
username
:
root
username
:
beyond
password
:
2018006709
password
:
Beyond2020#
swagger
:
swagger
:
enable
:
true
enable
:
true
...
...
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