Open siiinc opened 2 years ago
So in this case the route is found, but it is not used because it does not produce what the client is requesting.
I agree that it doesn't make sense in this case because the default response is also not what the client is requesting
So in this case the route is found, but it is not used because it does not produce what the client is requesting.
I agree that it doesn't make sense in this case because the default response is also not what the client is requesting Is there a better option to override the default micronaut error page/view in all error cases? Either want the service to respond according to the controller or with my own standard error response in all other cases.
@siiinc The ErrorResponseProcessor
API allows you control over the response when an error response is being sent. You can override the default implementation with your own
Expected Behavior
@Error( status = HttpStatus.NOT_ACCEPTABLE, global = true) annotated method should be run if a request is made with in correct Accept header
Actual Behaviour
The method is not used and the default error response is returned
Steps To Reproduce
curl --location --request GET 'localhost:8080/test/someid'
works as expectedcurl --location --request GET 'localhost:8080/testbad/someid'
works as expected ... @Error( status = HttpStatus.NOT_FOUND, global = true) annotated method is hitcurl --location --request GET 'localhost:8080/test/someid' --header 'Accept: image/jpeg'
does not work as expected. Default error page/view is returned{"message":"Not Acceptable","_embedded":{"errors":[{"message":"Specified Accept Types [image/jpeg] not supported. Supported types: [application/json]"}]},"_links":{"self":{"href":"/test/someid","templated":false}}}
Environment Information
MacOS Java 11 micronaut 3.3.3 and 2.7.x were tested with same results
Example Application
https://github.com/siiinc/micronaut-error-example.git
Version
3.3.3