Skip to content

unicorn/error-message Style

What it does

This rule enforces a message value to be passed in when creating an instance of a built-in Error object, which leads to more readable and debuggable code.

Why is this bad?

Examples

Examples of incorrect code for this rule:

javascript
throw Error();
throw new TypeError();

Examples of correct code for this rule:

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

References

Released under the MIT License.