-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use with Spring Cloud #9
Comments
Hey @chrisob55 - I'll take a look but I'll need to try to reproduce the issue. Do you by any chance have a zip of a sample of the issue you're seeing? Just trying to reproduce in my IDE. Thanks, |
Hello, I've found the same problem. Client.java
Service.java
Also, in the
|
Let me give it a try. Can you give me the exact spring dependencies so I
can make sure we're on same versions/etc and I can try to debug?
…On Mon, 21 Oct 2019, 17:05 Lucas Mota, ***@***.***> wrote:
Hello, I've found the same problem.
Here is a small example to give the idea of what I've tried to do, but
failed. All exceptions defined on the @errorHandling extends
AbstractRequestException. But all requests that mach the error codes fall
into the catch of the FeignException.
Client.java
@errorHandling(codeSpecific =
{
@errorcodes( codes = {400}, generate = PayloadException.class),
@errorcodes( codes = {403}, generate = ForbiddenException.class),
@errorcodes( codes = {404}, generate = UnknownResourceException.class),
},
defaultException = PayloadException.class
)
@FeignClient(value = "api", url = "${api.path}",
configuration = ClientConfiguration.class)
public interface Client {
@RequestMapping(method = RequestMethod.PUT, value = "/path", consumes = "application/json")
String ***@***.*** final String payload);
}
Service.java
@RestController
@RequestMapping(path = "/test")
public class Service {
private final Client client;
@Autowired
public Service(final Client client) {
this.client = client;
}
@GetMapping(path = "/a")
@responsebody
public String ***@***.*** final String id) {
try {
String body = "";
externalHouse = this.client.create(body);
} catch (AbstractRequestException e) {
log.error(e.getMessage());
} catch (FeignException e) {
log.error(e.getMessage());
}
}
}
Also, in the ClientConfiguration class, I've defined the following:
@bean
public ErrorDecoder errorDecoder() {
return AnnotationErrorDecoder.builderFor(Client.class).build();
}
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#9?email_source=notifications&email_token=ADJ2TCSPCJPGJWC5NK3GAZ3QPYYT7A5CNFSM4FRRI2J2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB4CJOI#issuecomment-544744633>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADJ2TCXWS6CB7GC42UUIWYDQPYYT7ANCNFSM4FRRI2JQ>
.
|
Hi @lucasm0ta , maybe you have solved the problem yourself, since it's a long time ago since you've opened this ticket. The AnnotationErrorDecoder requires methods to be annotated with @errorHandling to kick in. So if you annotate your Method simple with @errorHandling() it will work. |
It has been quite a long time! I really lost track of this issue as I used another approach at the time. Thank you for the note on this issue. While I'm not currently working with the code with said problem, I hope it helps other users 😄. In case I get back to it, I'll give it a try |
Hello guys I am getting this error when using
My Error decoder is as following:
My problem is that feign returns an empty body for 401 response (this is my testing use case, the service returns a custom response) I don't know all the error codes the service will return. I also tried creating a custom ErrorDecoder but inside the decode method the body of the Response object is also null.
I'd like to know if feign-annotation-error-decoder works for you guys with the latest version of Spring Cloud. Mi intention is to propagate the response for http error status codes. This json response change for the same error code according to the input data. Greetings. |
I'm facing the same error as @jnm-ronquillo. Any thoughts on that? EDIT: I was able to make it work, by using these specific versions:
|
There seems to be an issue when trying to use this within Spring Cloud/Eureka setup. Using the @FeignClient annoation
@FeignClient(name = "myResource", url = "${my.endpoint}", configuration = MyResourceConfig.class)
Defining the AnnotationErrorDecoder in the configuration means it doesn't work. Is there any there way of defining an AnnotationErrorDecoder (ideally leaving out the builderFor(XXXX.class) as this can cause a circular reference?
Thanks,
The text was updated successfully, but these errors were encountered: