Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
项目统一框架
amos-boot-biz
Commits
bfb2ab5b
Commit
bfb2ab5b
authored
Sep 26, 2021
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.feign调用异常,增加抛出错误方信息
parent
6510191a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
FeignBasicAuthRequestInterceptor.java
...sion/business/feign/FeignBasicAuthRequestInterceptor.java
+1
-0
FeignClientErrorDecoder.java
...s/supervision/business/feign/FeignClientErrorDecoder.java
+15
-8
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-supervision-biz/src/main/java/com/yeejoin/amos/supervision/business/feign/FeignBasicAuthRequestInterceptor.java
View file @
bfb2ab5b
...
...
@@ -36,6 +36,7 @@ public class FeignBasicAuthRequestInterceptor implements RequestInterceptor {
template
.
header
(
"token"
,
token
);
template
.
header
(
"product"
,
product
);
template
.
header
(
"appKey"
,
appKey
);
template
.
header
(
"clientType"
,
"feignClient"
);
}
}
amos-boot-module/amos-boot-module-biz/amos-boot-module-supervision-biz/src/main/java/com/yeejoin/amos/supervision/business/feign/FeignClientErrorDecoder.java
View file @
bfb2ab5b
package
com
.
yeejoin
.
amos
.
supervision
.
business
.
feign
;
import
com.alibaba.fastjson.JSONObject
;
import
feign.FeignException
;
import
feign.Response
;
import
feign.Util
;
import
feign.codec.ErrorDecoder
;
...
...
@@ -8,21 +10,26 @@ import lombok.extern.slf4j.Slf4j;
import
java.io.IOException
;
/**
* @author DELL
*/
@Slf4j
public
class
FeignClientErrorDecoder
implements
ErrorDecoder
{
public
class
FeignClientErrorDecoder
extends
ErrorDecoder
.
Default
{
@Override
public
Exception
decode
(
String
methodKey
,
Response
response
)
{
log
.
info
(
"feign client response:"
,
response
);
String
body
=
null
;
Exception
exception
=
super
.
decode
(
methodKey
,
response
);
String
message
;
try
{
body
=
Util
.
toString
(
response
.
body
().
asReader
());
if
(
exception
instanceof
FeignException
&&
((
FeignException
)
exception
).
responseBody
().
isPresent
())
{
String
body
=
Util
.
toString
(
response
.
body
().
asReader
());
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
body
);
message
=
jsonObject
.
getString
(
"devMessage"
);
return
new
RuntimeException
(
message
);
}
}
catch
(
IOException
e
)
{
log
.
error
(
"feign.IOException"
,
e
);
}
if
(
response
.
status
()
>=
400
&&
response
.
status
()
<=
500
)
{
return
null
;
}
return
null
;
return
exception
;
}
}
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