-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e161e16
commit c80f636
Showing
1 changed file
with
79 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
10μ₯/70_볡ꡬν _μ_μλ_μν©μλ_κ²μ¬μμΈλ₯Ό_νλ‘κ·Έλλ°_μ€λ₯μλ_λ°νμμμΈλ₯Ό_μ¬μ©νλΌ_κΉκ΄ν.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Item 70. 볡ꡬν μ μλ μν©μλ κ²μ¬ μμΈλ₯Ό, νλ‘κ·Έλλ° μ€λ₯μλ λ°νμ μμΈλ₯Ό μ¬μ©νλΌ | ||
## 1. ν΅μ¬ μ 리 | ||
- κ²μ¬ μμΈ: 볡ꡬν μ μλ μν© | ||
- λΉκ²μ¬ μμΈ: νλ‘κ·Έλλ° μ€λ₯, νΉμ νμ€νμ§ μμ μΌμ΄μ€ | ||
- throwable: μ μνμ§λ λ§μ | ||
- κ²μ¬ μμΈλΌλ©΄ 볡ꡬμ νμν μ 보λ₯Ό μλ €μ£Όλ λ©μλλ μ 곡νμ | ||
|
||
<br> | ||
|
||
## 2. κ²μ μμΈ (Checked Exception) | ||
- νΈμΆνλ μͺ½μμ 볡ꡬνλ¦¬λΌ μ¬κ²¨μ§λ μν©μ΄λΌλ©΄ `κ²μ¬ μμΈ`λ₯Ό μ¬μ©νλΌ. | ||
- 볡ꡬνλ€λ μλ―Έ ?? | ||
- νΈμΆμκ° μμΈλ₯Ό λ§μ£Όμ³€μ λ, λμνλ€λ μλ―Έ κ°λ€. | ||
|
||
|
||
- νΈμΆμκ° κ·Έ μμΈλ₯Ό `catcb` λ‘ μ‘μ μ²λ¦¬νκ±°λ λ λ°κΉ₯μΌλ‘ μ ννλλ‘ κ°μ νκ² λλ€. | ||
|
||
|
||
- API μ€κ³μλ API μ¬μ©μμκ² κ²μ¬ μμΈλ₯Ό λμ Έμ£Όμ΄ κ·Έ μνμμ ν볡ν΄λ΄λΌκ³ μꡬν κ²μ΄λ€. | ||
|
||
|
||
- ꡬ쑰 μμ | ||
- Exception μ μμ ν΄λμ€ μ€ RuntimeException μ μ μΈν λͺ¨λ ν΄λμ€λ CheckedException μ΄λ€. | ||
|
||
<br> | ||
|
||
<img width="500" src="https://user-images.githubusercontent.com/60383031/125167279-af979880-e1da-11eb-8beb-1af60424045a.png"> | ||
|
||
|
||
|
||
- μ½λ μμ | ||
```java | ||
public class ObjectMapper extends ObjectCodec implements Versioned, Serializable { | ||
// μ€λ΅ | ||
|
||
public void writeValue(DataOutput out, Object value) throws IOException { | ||
this._writeValueAndClose(this.createGenerator(out), value); | ||
} | ||
} | ||
``` | ||
|
||
|
||
<br> | ||
|
||
## 3. λΉκ²μ¬ μμΈ (Unchecked Exception) | ||
- λΉκ²μ¬ μμΈλ ? | ||
- μΌλ°μ μΌλ‘ νλ‘κ·Έλ¨μμ μ‘μ νμκ° μκ±°λ νΉμ μ‘μ§ λ§μμΌ νλ€. | ||
- λͺ μμ μΈ μμΈ μ²λ¦¬λ₯Ό κ°μ νμ§ μλ νΉμ§μ΄ μκΈ° λλ¬Έμ catch λ‘ μ‘κ±°λ throw λ‘ νΈμΆν λ©μλλ‘ μμΈλ₯Ό λμ§μ§ μμλ λλ€. | ||
- ꡬ쑰 μμ | ||
|
||
<br> | ||
<img width="500" src="https://user-images.githubusercontent.com/60383031/125167106-dc977b80-e1d9-11eb-8f3a-62891bdb19b0.png"> | ||
|
||
- λ°νμ μλ¬ | ||
- νλ‘κ·Έλλ° μ€λ₯λ₯Ό λνλΌ λλ λ°νμ μμΈλ₯Ό μ¬μ©νμ | ||
- ν΄λΉ μλ¬λ λλΆλΆ μ μ 쑰건μ λ§μ‘±νμ§ λͺ»νμ λ λ°μ | ||
- μ μ 쑰건 μμλ‘λ Index κ° μλ€. | ||
- Index λ 0 to Array.size() - 1 μ¬μ΄μ μμ΄μΌ νλ€. μ΄ μ μ μ‘°κ±΄μ΄ μλ°°κ° λλ€λ©΄ `ArrayIndexOfBoundsException` μ΄ λ°μνλ€. | ||
|
||
<br> | ||
|
||
## 4. μλ¬ (Error) | ||
- μλ¬ ??? | ||
- λ³΄ν΅ JVMμ΄ μμ λΆμ‘±, λΆλ³μ κΉ¨μ§ λ± λ μ΄μ μνμ κ³μν μ μλ μν©μ λνλΌ λ μ¬μ©νλ€. | ||
- Error λ μμ€ν λ 벨μμ μ¬κ°ν μμ€μ΄κΈ° λλ¬Έμ μμΈ‘νκ±°λ μ²λ¦¬ν μ μλ λ°©λ²μ΄ μλ€. | ||
|
||
- ꡬ쑰 μμ | ||
|
||
<br> | ||
<img width="500" src="https://user-images.githubusercontent.com/60383031/125167421-54b27100-e1db-11eb-9ab0-a0c6836e883d.png"> | ||
|
||
- μ£Όμ μ¬ν | ||
- Error λ μμνμ§ λ§μμΌν λΏ μλλΌ, throw λ¬ΈμΌλ‘ μ§μ λμ§λ μΌλ μμ΄μΌ νλ€. | ||
|
||
<br> | ||
|
||
#### μ°Έκ³ | ||
- https://www.nextree.co.kr/p3239/ | ||
- https://cheese10yun.github.io/checked-exception/ |