Web APIs

AbortSignal.throwIfAborted()

Try the free JavaScript compiler

Throw the stored reason if cancellation has been signaled. Otherwise return normally. Example console output: closed.

Formal Syntax & Structure

javascript syntaxjavascript
signal.throwIfAborted()

Return Value

undefined

No result when not aborted.

Working Example

Example Snippetjavascript
const c=new AbortController(); c.abort("closed"); try{c.signal.throwIfAborted()}catch(reason){console.log(reason)}
JavaScript Reference