It is a bad practice to throw something that's not derived at some level from Error. If you can't find an existing Error type that suitably conveys what you need to convey, then you should extend Error to create one.

Specifically, part of the point of throwing Errors is to communicate about the conditions of the error, but strings have far less ability to communicate meaningfully than Errors because they don't include stacktraces.

Noncompliant Code Example

throw "Invalid negative index.";        // Noncompliant

Compliant Solution

throw new Error("Invalid negative index.");

See