mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-02 11:41:04 +05:30
23 lines
564 B
TypeScript
23 lines
564 B
TypeScript
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 {
|
|
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;
|