Skip to content

Commit 250bc12

Browse files
committed
@uppy/utils: add cause support for AbortErrors
Refs: whatwg/webidl#1179
1 parent cc4c52a commit 250bc12

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
import hasOwnProperty from './hasProperty.js'
12
/**
23
* Little AbortController proxy module so we can swap out the implementation easily later.
34
*/
45
export const { AbortController } = globalThis
56
export const { AbortSignal } = globalThis
6-
export const createAbortError = (message = 'Aborted') => new DOMException(message, 'AbortError')
7+
export const createAbortError = (message = 'Aborted', options) => {
8+
const err = new DOMException(message, 'AbortError')
9+
if (options != null && hasOwnProperty(options, 'cause')) {
10+
Object.defineProperty(err, 'cause', { __proto__: null, configurable: true, writable: true, value: options.cause })
11+
}
12+
return err
13+
}

0 commit comments

Comments
 (0)