Skip to content

Commit 3498af5

Browse files
committed
DATACMNS-242 - Improved exception messages in QueryMethod.
1 parent e675e14 commit 3498af5

File tree

1 file changed

+6
-5
lines changed
  • spring-data-commons-core/src/main/java/org/springframework/data/repository/query

1 file changed

+6
-5
lines changed

spring-data-commons-core/src/main/java/org/springframework/data/repository/query/QueryMethod.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ public QueryMethod(Method method, RepositoryMetadata metadata) {
5353

5454
for (Class<?> type : Parameters.TYPES) {
5555
if (getNumberOfOccurences(method, type) > 1) {
56-
throw new IllegalStateException(
57-
String.format("Method must only one argument of type %s!", type.getSimpleName()));
56+
throw new IllegalStateException(String.format("Method must only one argument of type %s! Offending method: %s",
57+
type.getSimpleName(), method.toString()));
5858
}
5959
}
6060

6161
if (hasParameterOfType(method, Pageable.class)) {
6262
assertReturnTypeAssignable(method, Page.class, List.class);
6363
if (hasParameterOfType(method, Sort.class)) {
64-
throw new IllegalStateException("Method must not have Pageable *and* Sort parameter. "
65-
+ "Use sorting capabilities on Pageble instead!");
64+
throw new IllegalStateException(String.format("Method must not have Pageable *and* Sort parameter. "
65+
+ "Use sorting capabilities on Pageble instead! Offending method: %s", method.toString()));
6666
}
6767
}
6868

@@ -73,7 +73,8 @@ public QueryMethod(Method method, RepositoryMetadata metadata) {
7373
Assert.notNull(this.parameters);
7474

7575
if (isPageQuery()) {
76-
Assert.isTrue(this.parameters.hasPageableParameter(), "Paging query needs to have a Pageable parameter!");
76+
Assert.isTrue(this.parameters.hasPageableParameter(),
77+
String.format("Paging query needs to have a Pageable parameter! Offending method %s", method.toString()));
7778
}
7879
}
7980

0 commit comments

Comments
 (0)