Skip to content

Commit a6082b9

Browse files
committed
Explicitly renames exceptions in safe property retrieval
This makes it a lot more obvious in the test output!
1 parent 20996c6 commit a6082b9

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/test/java/com/ibm/watson/developer_cloud/WatsonServiceTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,27 @@ public static String getStringFromInputStream(InputStream is) {
7373

7474
public String getExistingProperty(String property) {
7575
String value = prop.getProperty(property);
76-
if(value == null) throw new IllegalStateException("A property expected to exist does not exist: " + property);
76+
if(value == null) throw new MissingPropertyException(property);
7777
return value;
7878
}
7979
public String getValidProperty(String property) {
8080
String value = getExistingProperty(property);
81-
if("".equals(value)) throw new IllegalStateException("Property " + property + " is empty. It's probably unset.");
81+
if("".equals(value)) throw new EmptyPropertyException(property);
8282
return value;
8383
}
8484

85+
private class MissingPropertyException extends IllegalStateException {
86+
MissingPropertyException(String property) {
87+
super("A property expected to exist does not exist: " + property);
88+
}
89+
}
90+
91+
private class EmptyPropertyException extends IllegalStateException {
92+
EmptyPropertyException(String property) {
93+
super("Property " + property + " is empty. It's probably unset.");
94+
}
95+
}
96+
8597
/**
8698
* Sets the up.
8799
*

0 commit comments

Comments
 (0)