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
Support for rendering exception response statuses in response codes #521
Comments
👍 +1 |
This feature would be awesome. Should be also supported when declaring @ExceptionHandler in "@ControllerAdvice" annotated classes. |
Awesome! Any plans for this issue? |
+1 |
+1 |
1 similar comment
+1 |
+1 |
1 similar comment
+1 |
Hi all, |
Not sure that it is easy. So any approach you take, if you solve the problem we'd be glad to accept your contribution. Perhaps easier to do via some (custom or otherwise) annotations. At a high level the problem with controller exception handler is that there is no way to know if your controller does not use checked exception without additional annotations. |
I couldn't find a way to the |
@benweet that is intentionally protected from being exposed. Would you mind explaining how you're using the method and we can see if we can abstract that on one of those contexts |
@dilipkrish I would have a class that implements the |
@benweet isnt that implementation details that is better supported by adding support for |
@dilipkrish I'm not really interested in @RequestMapping(
method = RequestMethod.POST,
path = "/api/requests",
produces = "application/json")
public RequestDto createRequest() throws InvalidApiKey { @ResponseStatus(
value = HttpStatus.FORBIDDEN,
reason = "Unknown or missing API key.")
public class InvalidApiKey extends Exception {
} And then implement the OperationBuilderPlugin like this: @Override
public void apply(OperationContext operationContext) {
...
// Get the java.lang.reflect.Method somehow
for (Class exceptionType: method.getExceptionTypes())
ResponseStatus responseStatus = errorType.getAnnotation(ResponseStatus.class);
if (responseStatus != null) {
HttpStatus httpStatus = responseStatus.value();
// Build the ResponseMessage
...
operationContext.operationBuilder().responseMessages(responseMessages);
... |
Ah got it, which is what this initial story was for. Thanks for clarifying. Yes, that requires that |
any volunteers? :) |
This is a little bit involved. Dont want to rush this into 3.0 which is due in a week |
should generate 404 as a response status for declared exceptions
The text was updated successfully, but these errors were encountered: