List of usage examples for io.netty.handler.codec.http HttpStatusClass SERVER_ERROR
HttpStatusClass SERVER_ERROR
To view the source code for io.netty.handler.codec.http HttpStatusClass SERVER_ERROR.
Click Source Link
From source file:com.ibasco.agql.core.AbstractWebApiInterface.java
License:Open Source License
/** * The default error handler. Override this if needed. * * @param response An instance of {@link AbstractWebApiResponse} or <code>null</code> if an exception was thrown. * @param error A {@link Throwable} instance or <code>null</code> if no error has occured. * * @throws WebException thrown if a server/client error occurs *//*from w w w . j av a 2 s . c o m*/ protected void interceptResponse(Res response, Throwable error) { if (error != null) throw new WebException(error); log.debug("Handling response for {}, with status code = {}", response.getMessage().getUri(), response.getMessage().getStatusCode()); if (response.getStatus() == HttpStatusClass.SERVER_ERROR || response.getStatus() == HttpStatusClass.CLIENT_ERROR) { switch (response.getMessage().getStatusCode()) { case 400: throw new BadRequestException("Incorrect parameters provided for request"); case 403: throw new AccessDeniedException( "Access denied, either because of missing/incorrect credentials or used API token does not grant access to the requested resource."); case 404: throw new ResourceNotFoundException("Resource was not found."); case 429: throw new TooManyRequestsException( "Request was throttled, because amount of requests was above the threshold defined for the used API token."); case 500: throw new UnknownWebException("An internal error occured in server"); case 503: throw new ServiceUnavailableException( "Service is temprorarily unavailable. Possible maintenance on-going."); default: throw new WebException("Unknown error occured on request send"); } } }