- Common ways to obtain RestLiServiceException
private void myMethod () {RestLiServiceException r =
HttpStatus status;String message;new RestLiServiceException(status, message)
HttpStatus status;Object[] object;Object[] args;new RestLiServiceException(status, String.format("<changeme>", object, args))
- Smart code suggestions by Codota
}
exception.setErrorDetails(new DataMap(ImmutableMap.of(LOCATION_301, leaderUri.toString()))); throw exception; } else {
@Override public Greeting get(Long key) { try { String s = (new String[0])[42]; } catch (ArrayIndexOutOfBoundsException e) { Greeting details = new Greeting().setMessage("Hello, Sorry for the mess"); throw new RestLiServiceException(HttpStatus.S_500_INTERNAL_SERVER_ERROR, "error processing request", e) .setServiceErrorCode(42).setErrorDetails(details.data()); } return null; }
exception.setErrorDetails(new DataMap(ImmutableMap.of(LOCATION_301, leaderUri.toString()))); throw exception; } else {
exception.setErrorDetails(new DataMap(ImmutableMap.of(LOCATION_301, leaderUri.toString()))); throw exception; } else {
/** * Responds with an error for requests to create insulting greetings, responds * with 201 created for all other requests. */ @RestMethod.Create public CreateResponse create(Greeting g) { if(g.hasTone() && g.getTone() == Tone.INSULTING) { RestLiServiceException notAcceptableException = new RestLiServiceException(HttpStatus.S_406_NOT_ACCEPTABLE, "I will not tolerate your insolence!"); DataMap details = new DataMap(); details.put("reason", "insultingGreeting"); notAcceptableException.setErrorDetails(details); notAcceptableException.setServiceErrorCode(999); throw notAcceptableException; } else { return new CreateResponse(g.getId(), HttpStatus.S_201_CREATED); } }