2018-11-04 10:09:42 +02:00
|
|
|
function RequestAbortedError(error: Error | Response) {
|
2019-11-27 11:03:32 +02:00
|
|
|
this.name = 'RequestAbortedError';
|
|
|
|
this.message = 'RequestAbortedError';
|
|
|
|
this.error = error;
|
|
|
|
this.stack = new Error().stack;
|
2018-11-04 10:09:42 +02:00
|
|
|
|
2019-11-27 11:03:32 +02:00
|
|
|
if (typeof error === 'string') {
|
|
|
|
this.message = error;
|
|
|
|
} else {
|
2019-12-07 13:28:52 +02:00
|
|
|
if ('message' in error) {
|
|
|
|
this.message = error.message;
|
|
|
|
}
|
|
|
|
|
2019-11-27 11:03:32 +02:00
|
|
|
this.error = error;
|
|
|
|
Object.assign(this, error);
|
|
|
|
}
|
2018-11-04 10:09:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
RequestAbortedError.prototype = Object.create(Error.prototype);
|
|
|
|
RequestAbortedError.prototype.constructor = RequestAbortedError;
|
|
|
|
|
|
|
|
export default RequestAbortedError;
|