DATACMNS-242 - Improved exception messages in QueryMethod.
This commit is contained in:
@@ -53,16 +53,16 @@ public class QueryMethod {
|
|||||||
|
|
||||||
for (Class<?> type : Parameters.TYPES) {
|
for (Class<?> type : Parameters.TYPES) {
|
||||||
if (getNumberOfOccurences(method, type) > 1) {
|
if (getNumberOfOccurences(method, type) > 1) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(String.format("Method must only one argument of type %s! Offending method: %s",
|
||||||
String.format("Method must only one argument of type %s!", type.getSimpleName()));
|
type.getSimpleName(), method.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasParameterOfType(method, Pageable.class)) {
|
if (hasParameterOfType(method, Pageable.class)) {
|
||||||
assertReturnTypeAssignable(method, Page.class, List.class);
|
assertReturnTypeAssignable(method, Page.class, List.class);
|
||||||
if (hasParameterOfType(method, Sort.class)) {
|
if (hasParameterOfType(method, Sort.class)) {
|
||||||
throw new IllegalStateException("Method must not have Pageable *and* Sort parameter. "
|
throw new IllegalStateException(String.format("Method must not have Pageable *and* Sort parameter. "
|
||||||
+ "Use sorting capabilities on Pageble instead!");
|
+ "Use sorting capabilities on Pageble instead! Offending method: %s", method.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +73,8 @@ public class QueryMethod {
|
|||||||
Assert.notNull(this.parameters);
|
Assert.notNull(this.parameters);
|
||||||
|
|
||||||
if (isPageQuery()) {
|
if (isPageQuery()) {
|
||||||
Assert.isTrue(this.parameters.hasPageableParameter(), "Paging query needs to have a Pageable parameter!");
|
Assert.isTrue(this.parameters.hasPageableParameter(),
|
||||||
|
String.format("Paging query needs to have a Pageable parameter! Offending method %s", method.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user