# Throwing Your Own Errors

When a function gets a value it can't use, throw new Error with a message that says what was wrong, make your own error class with extends Error for the problems your program knows about, and return a value instead when there's no mistake to report.

![Cheat sheet: Throwing Your Own Errors](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/10/ee9d9d73f0e44a57a2637fc0f624bdc9.webp)

- Category: JavaScript
- Level: Journeyman
- Tags: Custom Error, Error, extends, instanceof (javascript), JavaScript, software-development, throw (javascript)
- Updated: November 1, 2026

Source: https://www.ask-codey.com/cheat-sheets/javascript-errors-throwing-your-own-cheat-sheet
