Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
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
openSource
apollo
Commits
96d04faf
Commit
96d04faf
authored
Aug 15, 2016
by
张乐
Committed by
GitHub
Aug 15, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #381 from nobodyiam/global-exception-handler-fix
fix the potential error when handling exceptions
parents
5219b5c6
eaa877cf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
4 deletions
+12
-4
GlobalDefaultExceptionHandler.java
...ollo/common/controller/GlobalDefaultExceptionHandler.java
+12
-4
No files found.
apollo-common/src/main/java/com/ctrip/framework/apollo/common/controller/GlobalDefaultExceptionHandler.java
View file @
96d04faf
...
@@ -86,12 +86,20 @@ public class GlobalDefaultExceptionHandler {
...
@@ -86,12 +86,20 @@ public class GlobalDefaultExceptionHandler {
Map
<
String
,
Object
>
errorAttributes
=
new
HashMap
<>();
Map
<
String
,
Object
>
errorAttributes
=
new
HashMap
<>();
boolean
errorHandled
=
false
;
//如果是admin server引起的异常,则显示内部的异常信息
if
(
ex
instanceof
HttpStatusCodeException
)
{
if
(
ex
instanceof
HttpStatusCodeException
)
{
errorAttributes
=
gson
.
fromJson
(((
HttpStatusCodeException
)
ex
).
getResponseBodyAsString
(),
mapType
);
try
{
status
=
((
HttpStatusCodeException
)
ex
).
getStatusCode
();
//try to extract the original error info if it is thrown from apollo programs, e.g. admin service
}
else
{
errorAttributes
=
gson
.
fromJson
(((
HttpStatusCodeException
)
ex
).
getResponseBodyAsString
(),
mapType
);
status
=
((
HttpStatusCodeException
)
ex
).
getStatusCode
();
errorHandled
=
true
;
}
catch
(
Throwable
th
)
{
//ignore
}
}
if
(!
errorHandled
)
{
errorAttributes
.
put
(
"status"
,
status
.
value
());
errorAttributes
.
put
(
"status"
,
status
.
value
());
errorAttributes
.
put
(
"message"
,
message
);
errorAttributes
.
put
(
"message"
,
message
);
errorAttributes
.
put
(
"timestamp"
,
errorAttributes
.
put
(
"timestamp"
,
...
...
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