accounts-frontend/packages/app/services/request/RequestAbortedError.ts

23 lines
564 B
TypeScript
Raw Normal View History

function RequestAbortedError(error: Error | Response) {
this.name = 'RequestAbortedError';
this.message = 'RequestAbortedError';
this.error = error;
this.stack = new Error().stack;
if (typeof error === 'string') {
this.message = error;
} else {
2019-12-07 16:58:52 +05:30
if ('message' in error) {
this.message = error.message;
}
this.error = error;
Object.assign(this, error);
}
}
RequestAbortedError.prototype = Object.create(Error.prototype);
RequestAbortedError.prototype.constructor = RequestAbortedError;
export default RequestAbortedError;