Skip to content

Commit

Permalink
Rule methodsShouldNotThrowGenericException should check for Exception…
Browse files Browse the repository at this point in the history
… and RuntimeException
  • Loading branch information
mnhock authored and mnhock committed Jun 11, 2024
1 parent 9c800e1 commit 7bdf0ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/USERGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Taikai.builder()
.check();
```

- **Methods Should Not Throw Generic Exception**: Ensure that methods do not throw generic exceptions and use specific exception types instead.
- **Methods Should Not Throw Generic Exception**: Ensure that methods do not throw generic exceptions like `Exception` and `RuntimeException` and use specific exception types instead.

```java
Taikai.builder()
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/enofex/taikai/java/JavaConfigurer.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public JavaConfigurer methodsShouldNotThrowGenericException() {
public JavaConfigurer methodsShouldNotThrowGenericException(Configuration configuration) {
return addRule(TaikaiRule.of(methods()
.should().notDeclareThrowableOfType(Exception.class)
.as("Methods should not throw generic Exception"), configuration));
.orShould().notDeclareThrowableOfType(RuntimeException.class)
.as("Methods should not throw generic Exception or RuntimeException"), configuration));
}

public JavaConfigurer noUsageOfDeprecatedAPIs() {
Expand Down

0 comments on commit 7bdf0ac

Please sign in to comment.