Skip to content

Commit

Permalink
Cleanup the subclasses of FeatureMatcher which are currently try-catc…
Browse files Browse the repository at this point in the history
…h-ing
  • Loading branch information
alb-i986 committed Aug 23, 2020
1 parent 116c4dc commit 67452d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion hamcrest/src/main/java/org/hamcrest/FeatureMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public FeatureMatcher(Matcher<? super U> subMatcher, String featureDescription,
* @param actual the target object
* @return the feature to be matched
*/
protected abstract U featureValueOf(T actual);
protected abstract U featureValueOf(T actual) throws Exception;

@Override
protected boolean matchesSafely(T actual, Description mismatch) {
Expand Down
8 changes: 2 additions & 6 deletions hamcrest/src/main/java/org/hamcrest/io/FileMatchers.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,8 @@ public static Matcher<File> aFileNamed(final Matcher<String> expected) {

public static Matcher<File> aFileWithCanonicalPath(final Matcher<String> expected) {
return new FeatureMatcher<File, String>(expected, "A file with canonical path", "path") {
@Override protected String featureValueOf(File actual) {
try {
return actual.getCanonicalPath();
} catch (IOException e) {
return "Exception: " + e.getMessage();
}
@Override protected String featureValueOf(File actual) throws IOException {
return actual.getCanonicalPath();
}
};
}
Expand Down

0 comments on commit 67452d1

Please sign in to comment.