Item 73 - 추상화 수준에 맞는 예외를 던지라
추상화 수준에 맞는 예외를 던지라
Intro
예외 번역
public abstract class AbstractSequentialList<E> extends AbstractList<E> {
/**
* Returns the element at the specified position in this list.
*
* @param index index of the element to return
* @return the element at the specified position in this list
* @throws IndexOutOfBoundsException if the index is out of range
* (index < 0 || index >= size())
*/
public E get(int index) {
try {
return listIterator(index).next();
} catch (NoSuchElementException exc) {
throw new IndexOutOfBoundsException("Index: " + index);
}
}
}예외 연쇄
정리
Last updated