From fe8e48455ec50fca0e460283cdab804b54be35fd Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 27 Nov 2012 13:39:36 +0100 Subject: [PATCH] DATACMNS-253 - Improved exception message in ParameterOutOfBoundsException. --- .../repository/query/ParameterOutOfBoundsException.java | 8 ++++---- .../springframework/data/repository/query/Parameters.java | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/ParameterOutOfBoundsException.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/ParameterOutOfBoundsException.java index a9aace0762..f6514b0e53 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/ParameterOutOfBoundsException.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/ParameterOutOfBoundsException.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2010 the original author or authors. + * Copyright 2008-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,10 +28,10 @@ public class ParameterOutOfBoundsException extends RuntimeException { /** * Creates a new {@link ParameterOutOfBoundsException} with the given exception as cause. * + * @param message * @param cause */ - public ParameterOutOfBoundsException(Throwable cause) { - - super(cause); + public ParameterOutOfBoundsException(String message, Throwable cause) { + super(message, cause); } } diff --git a/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/Parameters.java b/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/Parameters.java index 88f64ba9be..c2085c84e5 100644 --- a/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/Parameters.java +++ b/spring-data-commons-core/src/main/java/org/springframework/data/repository/query/Parameters.java @@ -1,5 +1,5 @@ /* - * Copyright 2008-2011 the original author or authors. + * Copyright 2008-2012 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -165,7 +165,8 @@ public Parameter getParameter(int index) { try { return parameters.get(index); } catch (IndexOutOfBoundsException e) { - throw new ParameterOutOfBoundsException(e); + throw new ParameterOutOfBoundsException( + "Invalid parameter index! You seem to have declare too little query method parameters!", e); } }