| 387 | return this.#exception |
| 388 | } |
| 389 | async abort(exception) { |
| 390 | if (this.isCompleted || this.isStopped || this.hasFailed) { |
| 391 | return |
| 392 | } |
| 393 | if (typeof exception !== "undefined") { |
| 394 | if (typeof exception === "string") { |
| 395 | exception = new Error(exception) |
| 396 | } |
| 397 | if (typeof exception !== "object") { |
| 398 | throw new Error("exception is not an object.") |
| 399 | } |
| 400 | if (!(exception instanceof Error)) { |
| 401 | throw new Error("exception is not an Error or a string.") |
| 402 | } |
| 403 | } |
| 404 | const res = await fetch("/image/stop?task=" + this.id) |
| 405 | if (!res.ok) { |
| 406 | console.log("Stop response:", res) |
| 407 | throw new Error(res.statusText) |
| 408 | } |
| 409 | task_queue.delete(this) |
| 410 | this.#exception = exception |
| 411 | this.#status = exception ? TaskStatus.failed : TaskStatus.stopped |
| 412 | } |
| 413 | |
| 414 | get reqBody() { |
| 415 | if (this.#status === TaskStatus.init) { |