no-throw-literal
Disallow throwing literals as exceptions.
It is considered good practice to only throw
the Error
object itself or an
object using the Error
object as base objects for user-defined exceptions. The
fundamental benefit of Error
objects is that they automatically keep track of
where they were built and originated.
Invalid:
throw "error";
throw 0;
throw undefined;
throw null;
Valid:
throw new Error("error");