If you're developing internal system that won't go public then you can go with custom codes. On the other hand if you want to expose some APIs to public it's better to stick to the standard codes and provide more information in status reason phrase or in entity body.
In JAX-RS you can create your own statuses (or override reason phrases of standard statuses) like:
public static class CustomBadRequestType implements Response.StatusType {
@Override
public int getStatusCode() {
return 400;
}
@Override
public String getReasonPhrase() {
return "My Reason";
}
@Override
public Response.Status.Family getFamily() {
return Response.Status.Family.CLIENT_ERROR;
}
}
and then set the status to the Response.ResponseBuilder:
Response.status(new CustomBadRequestType()).build();