TheQuack45

Untitled

Oct 9th, 2014
529
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. public Response get(String urlPath, String cookie) throws RetrievalFailedException {
  2.        
  3.         try {
  4.             Response result = get(httpGetMethod().withUrl(ApiEndpointUtils.REDDIT_BASE_URL + urlPath).withCookie(cookie));
  5.             if (result == null) {
  6.                 throw new RetrievalFailedException("The given URI path does not exist on Reddit: " + urlPath);
  7.             } else {
  8.                 return result;
  9.             }
  10.         } catch (URISyntaxException e) {
  11.             throw new RetrievalFailedException("The syntax of the URI path was incorrect: " + urlPath);
  12.         } catch (InvalidURIException e) {
  13.             throw new RetrievalFailedException("The URI path was invalid: " + urlPath);
  14.         } catch (IOException e) {
  15.             throw new RetrievalFailedException("Input/output failed when retrieving from URI path: " + urlPath);
  16.         } catch (ParseException e) {
  17.             throw new RetrievalFailedException("Failed to parse the response from GET request to URI path: "+ urlPath);
  18.         }
  19.        
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment