Skip to content

Commit 67452d1

Browse files
committed
Cleanup the subclasses of FeatureMatcher which are currently try-catch-ing
1 parent 116c4dc commit 67452d1

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

hamcrest/src/main/java/org/hamcrest/FeatureMatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public FeatureMatcher(Matcher<? super U> subMatcher, String featureDescription,
3333
* @param actual the target object
3434
* @return the feature to be matched
3535
*/
36-
protected abstract U featureValueOf(T actual);
36+
protected abstract U featureValueOf(T actual) throws Exception;
3737

3838
@Override
3939
protected boolean matchesSafely(T actual, Description mismatch) {

hamcrest/src/main/java/org/hamcrest/io/FileMatchers.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,8 @@ public static Matcher<File> aFileNamed(final Matcher<String> expected) {
5050

5151
public static Matcher<File> aFileWithCanonicalPath(final Matcher<String> expected) {
5252
return new FeatureMatcher<File, String>(expected, "A file with canonical path", "path") {
53-
@Override protected String featureValueOf(File actual) {
54-
try {
55-
return actual.getCanonicalPath();
56-
} catch (IOException e) {
57-
return "Exception: " + e.getMessage();
58-
}
53+
@Override protected String featureValueOf(File actual) throws IOException {
54+
return actual.getCanonicalPath();
5955
}
6056
};
6157
}

0 commit comments

Comments
 (0)