Catch connection issues

Fixes #28
This commit is contained in:
Stuart Boston
2015-11-08 19:42:53 +00:00
parent 80414b7c2a
commit d1e1454134
2 changed files with 15 additions and 7 deletions
@@ -64,7 +64,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* Get the primary information about a TV episode by combination of a season and episode number.
* Get the primary information about a TV episode by combination of a season
* and episode number.
*
* @param tvID
* @param seasonNumber
@@ -106,7 +107,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* This method lets users get the status of whether or not the TV episode has been rated.
* This method lets users get the status of whether or not the TV episode
* has been rated.
*
* A valid session id is required.
*
@@ -159,7 +161,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* Get the external ids for a TV episode by comabination of a season and episode number.
* Get the external ids for a TV episode by comabination of a season and
* episode number.
*
* @param tvID
* @param seasonNumber
@@ -186,7 +189,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* Get the images (episode stills) for a TV episode by combination of a season and episode number.
* Get the images (episode stills) for a TV episode by combination of a
* season and episode number.
*
* @param tvID
* @param seasonNumber
@@ -214,7 +218,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* This method lets users rate a TV episode. A valid session id or guest session id is required.
* This method lets users rate a TV episode. A valid session id or guest
* session id is required.
*
* @param tvID
* @param seasonNumber
@@ -251,7 +256,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* Get the videos that have been added to a TV episode (teasers, clips, etc...)
* Get the videos that have been added to a TV episode (teasers, clips,
* etc...)
*
* @param tvID
* @param seasonNumber
@@ -128,7 +128,9 @@ public class HttpTools {
* @throws MovieDbException
*/
private String validateResponse(final DigestedResponse response, final URL url) throws MovieDbException {
if (response.getStatusCode() >= HttpStatus.SC_INTERNAL_SERVER_ERROR) {
if (response.getStatusCode() == 0) {
throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, response.getContent(), response.getStatusCode(), url, null);
} else if (response.getStatusCode() >= HttpStatus.SC_INTERNAL_SERVER_ERROR) {
throw new MovieDbException(ApiExceptionType.HTTP_503_ERROR, response.getContent(), response.getStatusCode(), url, null);
} else if (response.getStatusCode() >= HttpStatus.SC_MULTIPLE_CHOICES) {
throw new MovieDbException(ApiExceptionType.HTTP_404_ERROR, response.getContent(), response.getStatusCode(), url, null);