Examples of RetrievalFailedException


Examples of com.github.jreddit.exception.RetrievalFailedException

    @Test
    public void testParseFailedRetrieval() {
     
      // Stub REST client methods
      String url = "/some/fake/url";
      doThrow(new RetrievalFailedException("reason")).when(restClient).get(url, COOKIE);
        when(user.getCookie()).thenReturn(COOKIE);

        // Retrieve the submissions
        exception.expect(RetrievalFailedException.class);
        subject.parse(url);
View Full Code Here

Examples of com.github.jreddit.exception.RetrievalFailedException

    @Test
    public void testParseFailedRetrieval() {
     
      // Stub REST client methods
      String url = "/r/fake";
      doThrow(new RetrievalFailedException("reason")).when(restClient).get(url, COOKIE);
        when(user.getCookie()).thenReturn(COOKIE);

        // Retrieve the submissions
        exception.expect(RetrievalFailedException.class);
        subject.parse(url);
View Full Code Here

Examples of com.github.jreddit.exception.RetrievalFailedException

  public Response get(String urlPath, String cookie) throws RetrievalFailedException {
   
    try {
      Response result = get(httpGetMethod().withUrl(ApiEndpointUtils.REDDIT_BASE_URL + urlPath).withCookie(cookie));
      if (result == null) {
        throw new RetrievalFailedException("The given URI path does not exist on Reddit: " + urlPath);
      } else {
        return result;
      }
    } catch (URISyntaxException e) {
      throw new RetrievalFailedException("The syntax of the URI path was incorrect: " + urlPath);
    } catch (InvalidURIException e) {
      throw new RetrievalFailedException("The URI path was invalid: " + urlPath);
    } catch (IOException e) {
      throw new RetrievalFailedException("Input/output failed when retrieving from URI path: " + urlPath);
    } catch (ParseException e) {
      throw new RetrievalFailedException("Failed to parse the response from GET request to URI path: "+ urlPath);
    }
   
  }
View Full Code Here

Examples of com.github.jreddit.exception.RetrievalFailedException

    // Execute request
    Response response = httpClient.execute(request, responseHandler);
   
    // A HTTP error occurred
    if (response != null && response.getStatusCode() >= 300) {
      throw new RetrievalFailedException("HTTP Error (" + response.getStatusCode() + ") occurred for URI path: " + request.getURI().toString());
    }

    return response;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.