Re: [whatwg/dom] Variable strength aborting (Issue #1215)

You can attach data to the `Error` class:

```js
const reason = new Error('User clicked Kill Now')
reason.force = true

function aborted (event) {
  if (event.target.reason.force) {
    kill()
  } else {
    cancel()
  }
}
```

Or use two signals:


```js

let shuttingDown = false
process.on('SIGINT', () => {
  if (!shuttingDown) {
    // First interrupt, start graceful shutdown
    shuttingDown = true
    program.closed.then(() => { process.exit() })
    gracefulController.abort()
  } else {
    // Second interrupt, kill everything now
    forcefulController.abort()
  }
})
```


-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1215#issuecomment-1621372035
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1215/1621372035@github.com>

Received on Wednesday, 5 July 2023 09:25:16 UTC