Comments (7)
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,
-Fernando
from feign-annotation-error-decoder.
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 create(@RequestBody 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 makeRequest(@RequestParam 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();
}
from feign-annotation-error-decoder.
from feign-annotation-error-decoder.
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.
from feign-annotation-error-decoder.
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
from feign-annotation-error-decoder.
Hello guys I am getting this error when using
feign-annotation-error-decoder:1.3.0
spring-cloud-starter-openfeign:2.2.3.RELEASE
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
feign.error.ExceptionGenerator.<clinit>(ExceptionGenerator.java:44)
The following method did not exist:
feign.Request.create(Lfeign/Request$HttpMethod;Ljava/lang/String;Ljava/util/Map;Lfeign/Request$Body;)Lfeign/Request;
My Error decoder is as following:
@Bean
public ErrorDecoder errorDecoder() {
return AnnotationErrorDecoder.builderFor(Client.class).build();
}
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.
public ErrorDecoder errorDecoder() {
return new FeignClientExceptionErrorDecoder();
}
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.
from feign-annotation-error-decoder.
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:
implementation("org.springframework.cloud:spring-cloud-starter-openfeign:2.2.2.RELEASE")
implementation("io.github.openfeign:feign-annotation-error-decoder:1.3.0")
implementation("io.github.openfeign:feign-core:10.2.0")
from feign-annotation-error-decoder.
Related Issues (18)
- initial commit of annotation error decoder HOT 1
- Dont work use global interface HOT 5
- v1.0.3 does not work with feign-core 10.x.x HOT 10
- with move to feign-core 10.x.x, support capturing the request in Exception constructors HOT 6
- Add option to pass methodKey to exception constructor HOT 2
- AnnotationErrorDecoder throws IllegalStateException on validateGeneratorCanBeUsedToGenerateExceptions with null body and complex body decoder
- Use own ExceptionGenerator HOT 4
- [Question] [support needed] Error Response Body is empty HOT 1
- [Question] - Annotation based Retry After Exception HOT 5
- ErrorHandlerMap empty if only define annotation class
- [Question] Ignore custom exception constructors at startup
- Gradle dependency HOT 4
- Meta-annotation support HOT 1
- Upgrade to Feign 10.10.x HOT 12
- Upgrade 11.0 HOT 3
- Where can I find an example to use with Spring and @FeignClient
- documentation should be explicit about the custom exception constructor contract HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feign-annotation-error-decoder.