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
e460a5ef
Commit
e460a5ef
authored
Feb 01, 2020
by
段启岩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加调试模式
parent
4dde1cc5
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
2 deletions
+25
-2
src/main/java/cn/meteor/beyondclouds/common/handler/GlobalExceptionHandler.java
+18
-2
src/main/java/cn/meteor/beyondclouds/config/properties/BeyondCloudsProperties.java
+5
-0
src/main/resources/application-prod.yml
+1
-0
src/main/resources/application.yml
+1
-0
No files found.
src/main/java/cn/meteor/beyondclouds/common/handler/GlobalExceptionHandler.java
View file @
e460a5ef
package
cn
.
meteor
.
beyondclouds
.
common
.
handler
;
package
cn
.
meteor
.
beyondclouds
.
common
.
handler
;
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.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.web.HttpRequestMethodNotSupportedException
;
import
org.springframework.web.HttpRequestMethodNotSupportedException
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
...
@@ -15,16 +17,30 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -15,16 +17,30 @@ import javax.servlet.http.HttpServletRequest;
*/
*/
@RestControllerAdvice
@RestControllerAdvice
public
class
GlobalExceptionHandler
{
public
class
GlobalExceptionHandler
{
private
BeyondCloudsProperties
beyondCloudsProperties
;
@Autowired
public
GlobalExceptionHandler
(
BeyondCloudsProperties
beyondCloudsProperties
)
{
this
.
beyondCloudsProperties
=
beyondCloudsProperties
;
}
@ExceptionHandler
(
value
=
Exception
.
class
)
@ExceptionHandler
(
value
=
Exception
.
class
)
public
Response
<
String
>
exceptionHandler
(
HttpServletRequest
request
,
Exception
e
)
{
public
Response
<
String
>
exceptionHandler
(
HttpServletRequest
request
,
Exception
e
)
{
e
.
printStackTrace
();
boolean
debugMode
=
beyondCloudsProperties
.
getDebug
();
if
(
debugMode
)
{
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
());
}
else
if
(
e
instanceof
HttpRequestMethodNotSupportedException
){
}
else
if
(
e
instanceof
HttpRequestMethodNotSupportedException
){
return
Response
.
error
(
ErrorCode
.
OPERATION_FAILED
.
code
(),
e
.
getMessage
());
return
Response
.
error
(
ErrorCode
.
OPERATION_FAILED
.
code
(),
e
.
getMessage
());
}
else
{
}
else
{
return
Response
.
error
();
if
(
debugMode
)
{
return
Response
.
error
(
ErrorCode
.
OPERATION_FAILED
.
code
(),
e
.
getMessage
());
}
else
{
return
Response
.
error
();
}
}
}
}
}
}
}
src/main/java/cn/meteor/beyondclouds/config/properties/BeyondCloudsProperties.java
View file @
e460a5ef
...
@@ -27,6 +27,11 @@ public class BeyondCloudsProperties {
...
@@ -27,6 +27,11 @@ public class BeyondCloudsProperties {
}
}
/**
/**
* debug模式开关
*/
private
Boolean
debug
;
/**
* 认证配置
* 认证配置
*/
*/
private
AuthProperties
auth
;
private
AuthProperties
auth
;
...
...
src/main/resources/application-prod.yml
View file @
e460a5ef
...
@@ -27,6 +27,7 @@ mybatis-plus:
...
@@ -27,6 +27,7 @@ mybatis-plus:
mapper-locations
:
classpath*:cn/meteor/beyondclouds/modules/**/xml/*.xml
mapper-locations
:
classpath*:cn/meteor/beyondclouds/modules/**/xml/*.xml
beyondclouds
:
beyondclouds
:
debug
:
true
auth
:
auth
:
qq
:
qq
:
client-id
:
101846021
client-id
:
101846021
...
...
src/main/resources/application.yml
View file @
e460a5ef
...
@@ -27,6 +27,7 @@ mybatis-plus:
...
@@ -27,6 +27,7 @@ mybatis-plus:
mapper-locations
:
classpath*:cn/meteor/beyondclouds/modules/**/xml/*.xml
mapper-locations
:
classpath*:cn/meteor/beyondclouds/modules/**/xml/*.xml
beyondclouds
:
beyondclouds
:
debug
:
true
auth
:
auth
:
qq
:
qq
:
client-id
:
101846021
client-id
:
101846021
...
...
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