Skip to content

Files

Latest commit

 

History

History
21 lines (15 loc) · 479 Bytes

error-message.md

File metadata and controls

21 lines (15 loc) · 479 Bytes

Pattern: Missing message in Error constructor

Issue: -

Description

Creating Error objects without a message parameter reduces code readability and makes debugging more difficult. Always include a descriptive error message when throwing errors.

Examples

Example of incorrect code:

throw Error();
throw new TypeError();

Example of correct code:

throw new Error("Unexpected token");
throw new TypeError("Number expected");