Reputation: 10419
I am using an ExceptionMapper in JAX-RS.
public class MyException implements ExceptionMapper<ConstraintViolationException> {
@Override
public Response toResponse(ConstraintViolationException exception) {
...
}
}
all works. However, is there anyway I can get a handle to the URL, or the HTTP request that generated the exception?
Thanks
Upvotes: 2
Views: 836
Reputation: 130917
Inject UriInfo
using @Context
:
@Context
private UriInfo uriInfo;
Then use the getRequestUri()
method to get request URI:
URI uri = uriInfo.getRequestUri();
Refer to this answer for other types that can be injected with @Context
.
Upvotes: 2