uppy/packages/@uppy/utils/src/ErrorWithCause.js
Renée Kooi b22a812db3
Propagate isNetworkError through error wrappers (#3620)
The `ErrorWithCause` class uses the same signature as the builtin Error
does, but it supports the `{ cause }` option in older environments, and
it propagates the `isNetworkError` property from the underlying error.
2022-04-05 15:57:25 +02:00

13 lines
339 B
JavaScript

const hasProperty = require('./hasProperty')
class ErrorWithCause extends Error {
constructor (message, options = {}) {
super(message)
this.cause = options.cause
if (this.cause && hasProperty(this.cause, 'isNetworkError')) {
this.isNetworkError = this.cause.isNetworkError
}
}
}
module.exports = ErrorWithCause