[COLLECTIONS-399] added more context information when throwing a NoSuchElementException.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1352213 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cb9f11c0c3
commit
37da8fcbc2
|
@ -277,8 +277,11 @@ public class BoundedFifoBuffer<E> extends AbstractCollection<E>
|
|||
* @throws NoSuchElementException if the requested position is outside the range [0, size)
|
||||
*/
|
||||
public E get(int index) {
|
||||
if (index < 0 || index >= size()) {
|
||||
throw new NoSuchElementException();
|
||||
final int sz = size();
|
||||
if (index < 0 || index >= sz) {
|
||||
throw new NoSuchElementException(
|
||||
String.format("The specified index (%1$d) is outside the available range [0, %2$d)",
|
||||
index, sz));
|
||||
}
|
||||
|
||||
final int idx = (start + index) % maxElements;
|
||||
|
|
Loading…
Reference in New Issue