import { FetchError } from "../starnameClient/http"; export interface Task { run(): Promise; abort(): void; } export class Task implements Task { public static toPromise(task: Task): Promise { return task.run(); } public run(): Promise { throw new Error("tasks must implement run"); } public abort(): void { throw new Error("tasks must implement abort"); } } export type TaskError = Error; export const TaskAbortedError: FetchError = new FetchError(-1, "Aborted", [ "Task Aborted", ]);