mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-27 20:27:13 +00:00
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.
13 lines
339 B
JavaScript
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
|