Skip to content
This repository was archived by the owner on Jan 8, 2023. It is now read-only.

Commit c59f424

Browse files
committed
Add more descriptive exception handling
1 parent 9e1104f commit c59f424

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/main/java/io/github/spair/byond/dmi/DmiSlurper.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ public static Dmi slurpUp(final File dmiFile) {
2828
try (InputStream input = new FileInputStream(dmiFile)) {
2929
return slurpUp(dmiFile.getName(), input);
3030
} catch (FileNotFoundException e) {
31-
throw new IllegalArgumentException("Received DMI file doesn't exist");
31+
throw new IllegalArgumentException("Received DMI file doesn't exist. File path: " + dmiFile.getPath());
3232
} catch (IOException e) {
33-
throw new IllegalArgumentException("Received DMI can't be read");
33+
throw new IllegalArgumentException("Received DMI can't be read. File path: " + dmiFile.getPath());
34+
} catch (Exception e) {
35+
throw new RuntimeException("Unable to slur up dmi file. File path: " + dmiFile.getPath());
3436
}
3537
}
3638

@@ -44,7 +46,7 @@ public static Dmi slurpUp(final String dmiName, final String base64content) {
4446
try (InputStream input = new ByteArrayInputStream(Base64.getMimeDecoder().decode(base64content))) {
4547
return slurpUp(dmiName, input);
4648
} catch (IOException e) {
47-
throw new IllegalArgumentException("Received base64 content can't be read");
49+
throw new IllegalArgumentException("Received base64 content can't be read. Dmi name: " + dmiName);
4850
}
4951
}
5052

@@ -66,7 +68,9 @@ public static Dmi slurpUp(final String dmiName, final InputStream input) {
6668

6769
return new Dmi(dmiName, dmiImage.getWidth(), dmiImage.getHeight(), dmiMeta, dmiStates);
6870
} catch (IOException e) {
69-
throw new IllegalArgumentException("Received DMI can't be read");
71+
throw new IllegalArgumentException("Received DMI can't be read. Dmi name: " + dmiName);
72+
} catch (Exception e) {
73+
throw new RuntimeException("Unable to slurp up dmi input. Dmi name: " + dmiName);
7074
}
7175
}
7276

src/main/java/io/github/spair/byond/dmi/MetaExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private static IIOMetadata readMetadata(final InputStream input) {
5858

5959
return image.getMetadata();
6060
} catch (IOException e) {
61-
throw new IllegalArgumentException("DMI meta can't be read", e);
61+
throw new IllegalArgumentException("DMI meta can't be read");
6262
}
6363
}
6464

0 commit comments

Comments
 (0)