Skip to content

Commit 278b894

Browse files
committed
[프라미스와 에러 핸들링] upstream 병합 충돌 해결
1 parent ef69255 commit 278b894

1 file changed

Lines changed: 1 addition & 8 deletions

File tree

1-js/11-async/04-promise-error-handling/article.md

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,8 @@ Node.js같은 기타 호스트 환경에도 처리하지 못한 에러를 다루
198198

199199
## 요약
200200

201-
<<<<<<< HEAD
202201
- `.catch` 는 프라미스에서 발생한 모든 에러를 다룹니다. `reject()`가 호출되거나 에러가 던져지면 `.catch`에서 이를 처리합니다.
202+
- `.then`도 두 번째 인수(에러 핸들러)가 주어지면 같은 방식으로 에러를 잡을 수 있습니다.
203203
- `.catch`는 에러를 처리하고 싶은 지점에 정확히 위치시켜야 합니다. 물론 어떻게 에러를 처리할지 알고 있어야 하죠. 핸들러에선 에러를 분석하고(커스텀 에러 클래스가 이때 도움이 됩니다) 알 수 없는 에러(프로그래밍 실수로 발생한 에러일 확률이 높습니다)는 다시 던질 수 있습니다.
204204
- 에러 발생 시, 회복할 방법이 없다면 `.catch`를 사용하지 않아도 괜찮습니다.
205205
- `unhandledrejection` 이벤트 핸들러를 사용해 처리되지 않은 에러를 추적하고, 이를 사용자(혹은 서버에)에게 알려서 애플리케이션이 아무런 설명도 없이 '그냥 죽는걸' 방지합시다. 브라우저 환경에선 예방에 `unhandledrejection`을, 다른 환경에선 유사한 핸들러를 사용할 수 있습니다.
206-
=======
207-
- `.catch` handles errors in promises of all kinds: be it a `reject()` call, or an error thrown in a handler.
208-
- `.then` also catches errors in the same manner, if given the second argument (which is the error handler).
209-
- We should place `.catch` exactly in places where we want to handle errors and know how to handle them. The handler should analyze errors (custom error classes help) and rethrow unknown ones (maybe they are programming mistakes).
210-
- It's ok not to use `.catch` at all, if there's no way to recover from an error.
211-
- In any case we should have the `unhandledrejection` event handler (for browsers, and analogs for other environments) to track unhandled errors and inform the user (and probably our server) about them, so that our app never "just dies".
212-
>>>>>>> upstream/master

0 commit comments

Comments
 (0)