Reputation: 717
I'm running into the issue of having to differentiate between two error cases which both throw a Java BadrequestException, which shows up as having a 400 error code. I've extended BadrequestException to create a CustomException, but this Exception also throws a 400. Is there a way to have a custom exception throw an "unassigned" error code, like 469, for example? And how would I go about doing that?
Upvotes: 0
Views: 2681
Reputation: 14035
Assuming you are using JAX-RS you can create a new exception with a custom HTTP status code like so:
public class CustomException extends WebApplicationException {
private static final long serialVersionUID = 1L;
public CustomException() {
super(469);
}
}
Upvotes: 1