sharkey/packages/megalodon/src/cancel.ts

14 lines
290 B
TypeScript
Raw Normal View History

2023-09-24 01:49:47 +09:00
export class RequestCanceledError extends Error {
2023-09-25 08:20:03 +09:00
public isCancel: boolean;
2023-09-24 01:49:47 +09:00
2023-09-25 08:20:03 +09:00
constructor(msg: string) {
super(msg);
this.isCancel = true;
Object.setPrototypeOf(this, RequestCanceledError);
}
2023-09-24 01:49:47 +09:00
}
export const isCancel = (value: any): boolean => {
2023-09-25 08:20:03 +09:00
return value && value.isCancel;
};