Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 899 Bytes

error-message.md

File metadata and controls

40 lines (28 loc) · 899 Bytes

Enforce passing a message value when creating a built-in error

💼 This rule is enabled in the ✅ recommended config.

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.

Fail

throw Error();
throw Error('');
throw new TypeError();
const error = new AggregateError(errors);

Pass

throw Error('Unexpected property.');
throw new TypeError('Array expected.');
const error = new AggregateError(errors, 'Promises rejected.');