> For the complete documentation index, see [llms.txt](https://april.gitbook.io/learning-js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://april.gitbook.io/learning-js/chapter-11./11.3.md).

# 11.3 에러 일으키기

* 자바스크립트가 에러를 일으키기만 기다릴 필요 없이 직접 에러를 일으켜서 예외 처리 작업을 할 수 있음
  * **throw** : 현재 함수는 즉시 실행을 멈춤
  * **raise**
* 다른 언어와 달리 자바스크립트는 에러를 일으킬 때 *객체, 숫자, 문자열 등 어떤 값이든* catch 절에 넘길 수 있음 **=> Error 인스턴스를 넘기는 것이 가장 편리**

\[예제] 계좌의 잔고가 요청받은 금액보다 적으면? => 예외 발생

```javascript
function billPay(amount, payee, account) {
    if (amount > account.balance)
      throw new Error("insufficient funds");
    account.transfer(payee, amount);
}
```
