Skip to content

Commit

Permalink
@uppy/utils: add cause support for AbortErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Nov 7, 2022
1 parent cc4c52a commit 250bc12
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/@uppy/utils/src/AbortController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import hasOwnProperty from './hasProperty.js'
/**
* Little AbortController proxy module so we can swap out the implementation easily later.
*/
export const { AbortController } = globalThis
export const { AbortSignal } = globalThis
export const createAbortError = (message = 'Aborted') => new DOMException(message, 'AbortError')
export const createAbortError = (message = 'Aborted', options) => {
const err = new DOMException(message, 'AbortError')
if (options != null && hasOwnProperty(options, 'cause')) {
Object.defineProperty(err, 'cause', { __proto__: null, configurable: true, writable: true, value: options.cause })
}
return err
}

0 comments on commit 250bc12

Please sign in to comment.