Skip to Content
자바스크립트 완벽 가이드
book

자바스크립트 완벽 가이드

by David Flanagan, Han Seon- yong
February 2022
Beginner to intermediate
784 pages
24h 53m
Korean
Insight
Content preview from 자바스크립트 완벽 가이드
the De󼴩nitive Guide
407
13.2 프라미스
13.2.4
󼧓󺱋󻃇󻝳󻬏󽴔󻪟󺲻
이 장 초반에서
.then()
메서드에 두 번째 콜백 함수를 전달할 수 있으며 프라미스
가 거부되면 이 함수가 호출된다고 했습니다. 프라미스가 거부됐을 때 두 번째 콜
백 함수에 전달되는 인자는 거부 사유를 나타내는 값이며 일반적으로 Error 객체입
니다. 또한 앞에서
.then()
메서드에 콜백 두 개를 전달하는 일은 흔치 않다고 했습
니다. 프라미스 관련 에러는 일반적으로 프라미스 체인에
.catch()
메서드를 추가
하는 식으로 처리합니다. 프라미스 체인에 대해 설명했으니 이제 에러 처리에 대해
더 자세히 살펴보겠습니다. 설명에 앞서 비동기 프로그래밍에서는 에러 처리가 정
말 중요하다는 점을 강조합니다. 동기적 코드에서는 에러 처리 코드가 없으면 최
소한 예외가 발생하고, 스택 추적을 통해 어디서 무엇이 잘못됐는지 파악할 수 있
습니다. 비동기 코드에서는 처리하지 않은 예외가 아무런 경고 없이 사라질 때가
많고 에러도 조용히 일어날 때가 많으므로 디버그하기가 무척 어렵습니다. 다행히
.catch()
메서드를 사용하면 프라미스 에러를 쉽게 처리할 수 있습니다.
󻬏󼴩󺼣󻗫󺦫
프라미스의
.catch()
메서드는
null
을 첫 번째 인자로, 에러 처리 콜백을 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

코드로 인프라 관리하기(2판)

코드로 인프라 관리하기(2판)

키프 모리스

Publisher Resources

ISBN: 9788966263462