Caught new image exception error

master
Omertron 14 years ago
parent c8385c51cc
commit ad31df723c

@ -6,7 +6,7 @@ public class MovieDbException extends Exception {
public enum MovieDbExceptionType {
UNKNOWN_CAUSE, INVALID_URL, HTTP_404_ERROR, MOVIE_ID_NOT_FOUND, MAPPING_FAILED, CONNECTION_ERROR;
UNKNOWN_CAUSE, INVALID_URL, HTTP_404_ERROR, MOVIE_ID_NOT_FOUND, MAPPING_FAILED, CONNECTION_ERROR, INVALID_IMAGE;
}
private final MovieDbExceptionType exceptionType;
private final String response;

@ -423,24 +423,18 @@ public class TheMovieDb {
* @return
*/
public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException {
URL returnUrl = null;
StringBuilder sb;
if (!tmdbConfig.isValidSize(requiredSize)) {
sb = new StringBuilder();
sb.append(" - Invalid size requested: ").append(requiredSize);
LOGGER.warn(sb.toString());
return returnUrl;
throw new MovieDbException(MovieDbExceptionType.INVALID_IMAGE, requiredSize);
}
try {
sb = new StringBuilder(tmdbConfig.getBaseUrl());
StringBuilder sb = new StringBuilder(tmdbConfig.getBaseUrl());
sb.append(requiredSize);
sb.append(imagePath);
try {
return (new URL(sb.toString()));
} catch (MalformedURLException ex) {
LOGGER.warn("Failed to create image URL: " + ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.INVALID_URL, returnUrl.toString());
throw new MovieDbException(MovieDbExceptionType.INVALID_URL, sb.toString());
}
}

Loading…
Cancel
Save