Package com.arnaudpiroelle.marvel.api.objects.ref

Examples of com.arnaudpiroelle.marvel.api.objects.ref.ErrorResponse


*/
public class RestServiceErrorHandler implements ErrorHandler {
    @Override
    public Throwable handleError(RetrofitError cause) {
        Response r = cause.getResponse();
        ErrorResponse data = (ErrorResponse) cause.getBodyAs(ErrorResponse.class);

        if (r != null) {
            if (r.getStatus() == 401) {
                return new AuthorizationException(data.getMessage(), cause);
            } else if (r.getStatus() == 403) {
                //TODO: Forbidden
            } else if (r.getStatus() == 404) {
                return new EntityNotFoundException(data.getMessage(), cause);
            } else if (r.getStatus() == 405) {
                //TODO: Method Not Allowed
            } else if (r.getStatus() == 409) {
                return new QueryException(data.getMessage(), cause);
            } else if (r.getStatus() == 429) {
                return new RateLimitException(data.getMessage(), cause);
            }


        }

View Full Code Here

TOP

Related Classes of com.arnaudpiroelle.marvel.api.objects.ref.ErrorResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.