Skip to content

Throw a JavaScript Error instead of throwing a literal #1735

Closed
@aqueenan

Description

@aqueenan

Motivation

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 as described at https://eslint.org/docs/rules/no-throw-literal.

Proposed Solution

Instead of throw x; use throw new Error(x); (except for undefined, null and Symbol as raised in #1734).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions