GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — 아이템 73. 추상화 수준에 맞는 예외를 던지라 - Fin · Issue #181 · Study-2-Effective-Java/Effective-Java Open Labels 10장 예외이펙티브 자바 10장 (예외)이펙티브 자바 10장 (예외) DescriptionDiscussed in https://github.com/orgs/Study-2-Effective-Java/discussions/172Originally posted by bunsung92 March 21, 2023
Table of contents generated with markdown-toc 0. TL;DR 📚
1. 잘못 처리된 예외
2. 예외 번역(Exception Translation)위와 같은 상황에서의 해결책으로 제시 될 수 있는 방법이다.
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); } } }
3. 예외 연쇄(exception chanining)문제의 근본 원인(cause)인 저수준 예외를 고수준 예외에 실어 보내는 방식이다.
class HigherLevelException extends Exception { HigherLevelException(Throwable cause) { super(cause); } } class ChildClass { public void publicAPIMethod() { try { //do somthing... } catch (LowerLevelException cause) { throw new HigherLevelException(cause); } } }
3.1 차선책
4. 최종 정리 📚그래서 추상화 수준에 맞는 예외는 무엇일까? 🤔
5. 회고 🧹2023-03-26 일
ActivityMetadataMetadataAssigneesLabels10장 예외이펙티브 자바 10장 (예외)이펙티브 자바 10장 (예외) TypeProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |