Other small fixes

This commit is contained in:
filoghost 2014-12-21 15:25:23 +01:00
parent 19c1a356f7
commit 15828f320d
2 changed files with 13 additions and 4 deletions

View File

@ -116,14 +116,15 @@ public class ReadimageCommand extends HologramSubCommand {
} catch (MalformedURLException e) {
throw new CommandException("The provided URL was not valid.");
} catch (FileNotFoundException e) {
throw new CommandException("The image '" + args[1] + "' doesn't exist in the plugin's folder.");
} catch (TooWideException e) {
throw new CommandException("The image is too large. Max width allowed is " + ImageMessage.MAX_WIDTH + " pixels.");
} catch (UnreadableImageException e) {
throw new CommandException("The plugin was unable to read the image. Be sure that the format is supported.");
} catch (FileNotFoundException e) {
throw new CommandException("The image \"" + args[1] + "\" doesn't exist in the plugin's folder.");
} catch (IOException e) {
throw new CommandException("I/O exception while reading the image." + (isUrl ? "Is the URL valid?" : "Is it in use?"));
e.printStackTrace();
throw new CommandException("I/O exception while reading the image. " + (isUrl ? "Is the URL valid?" : "Is it in use?"));
} catch (Exception e) {
e.printStackTrace();
throw new CommandException("Unhandled exception while reading the image! Please look the console.");

View File

@ -19,6 +19,10 @@ public class FileUtils {
public static List<String> readLines(File file) throws IOException, Exception {
if (!file.isFile()) {
throw new FileNotFoundException(file.getName());
}
BufferedReader br = null;
try {
@ -49,7 +53,11 @@ public class FileUtils {
}
public static BufferedImage readImage(File file) throws UnreadableImageException, IOException, Exception {
if (!file.isFile()) {
throw new FileNotFoundException(file.getName());
}
BufferedImage image = ImageIO.read(file);
if (image == null) {