Skip to content

Require using Error objects as Promise rejection reasons (prefer-promise-reject-errors) #777

@feross

Description

@feross

This rule aims to ensure that Promises are only rejected with Error objects.

It is considered good practice to only pass instances of the built-in Error object to the reject() function for user-defined errors in Promises. Error objects automatically store a stack trace, which can be used to debug an error by determining where it came from. If a Promise is rejected with a non-Error value, it can be difficult to determine where the rejection occurred.

http://eslint.org/docs/rules/prefer-promise-reject-errors

Rule:

prefer-promise-reject-errors: "error"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions