Browse files

Improved exception handling for unreadable sobi files - refs #10206

  • Loading branch information...
1 parent d177c47 commit 5e0444fca79680d2d2067eb2659b7e2e1a42492a @McSquirrel McSquirrel committed Jun 8, 2016
View
2 src/main/java/gov/nysenate/openleg/model/sobi/SobiFile.java
@@ -83,7 +83,7 @@ public String getText() {
return FileUtils.readFileToString(file, encoding);
}
catch (IOException e) {
- throw new RuntimeException("Failed to read text from SobiFile:" + this.toString());
+ throw new UnreadableSobiEx(this, e);
}
}
View
19 src/main/java/gov/nysenate/openleg/model/sobi/UnreadableSobiEx.java
@@ -0,0 +1,19 @@
+package gov.nysenate.openleg.model.sobi;
+
+/**
+ * This exception is thrown when the contents of a sobi file cannot be read
+ */
+public class UnreadableSobiEx extends RuntimeException {
+
+ private static final long serialVersionUID = 8708541650408827491L;
+
+ private SobiFile sobiFile;
+
+ public UnreadableSobiEx(SobiFile sobiFile, Throwable cause) {
+ super("Could not read text from sobi file: " + sobiFile, cause);
+ }
+
+ public SobiFile getSobiFile() {
+ return sobiFile;
+ }
+}

0 comments on commit 5e0444f

Please sign in to comment.