You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@ProviderpublicclassAppExceptionMapperimplementsExceptionMapper<Exception> {
@ContextprivateHttpServletRequesthttpRequest;
@OverridepublicResponsetoResponse(finalExceptione) {
if (einstanceofValidationException) {
// return a custom Response here
}
// other mappers
}
}
And have it registered as environment.jersey().register(new AppExceptionMapper());
This would work when in my code I do throw new ValidationException(...). However, I have swagger annotations for validating the request:
When this validation fails, my custom exception mapper does not catch it, and the generic exception is returned. I put a breakpoint inside ValidationException, and swagger does throw this exception, but for some reason, my exception mapper is not catching it.
How come?
The text was updated successfully, but these errors were encountered:
Note that the referenced CustomExceptionMapperclass must implement javax.ws.rs.ext.ExceptionMapper<ValidationException> and therefore use javax.validation.ValidationException as parameter to toResponse to override the default jersey implementation (and Dropwizards override itself unless you already disabled that with registerDefaultExceptionMappers=false). This means you cannot use a generic exception mapper for the whole application.
I have a custom exception mapper:
And have it registered as
environment.jersey().register(new AppExceptionMapper());
This would work when in my code I do
throw new ValidationException(...)
. However, I have swagger annotations for validating the request:When this validation fails, my custom exception mapper does not catch it, and the generic exception is returned. I put a breakpoint inside
ValidationException
, and swagger does throw this exception, but for some reason, my exception mapper is not catching it.How come?
The text was updated successfully, but these errors were encountered: