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 { 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 MovieDbExceptionType exceptionType;
private final String response; private final String response;

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