Skip to content

Encourage use of AbortError for cancellation? #927

Closed
@jakearchibald

Description

@jakearchibald

Bit of a half baked idea, but should we make it easier to throw abort errors from signals? Something like:

AbortSignal.prototype.assertNotAborted = function(message = 'Aborted') {
  if (this.aborted) throw new DOMException(message, 'AbortError');
};

I know it's a one-liner, but it might encourage using the right kind of error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    addition/proposalNew features or enhancementsneeds implementer interestMoving the issue forward requires implementers to express interesttopic: abortingAbortController and AbortSignal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions