Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 504 Bytes

error-message.md

File metadata and controls

39 lines (27 loc) · 504 Bytes

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

This rule enforces a message value to be passed in when throwing 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 err = new Error();
throw err;

Pass

throw Error('Foo');
throw new TypeError('Foo');
const err = new Error('Foo');
throw err;