import { isJobCanceled } from "./inflight.js";
export const GENERATION_CANCELED_CODE = "GENERATION_CANCELED";
export function makeGenerationCanceledError() {
    const err = new Error("Generation canceled");
    err.status = 499;
    err.code = GENERATION_CANCELED_CODE;
    return err;
}
export function isGenerationCanceledError(value) {
    return Boolean(value &&
        typeof value === "object" &&
        "code" in value &&
        value.code === GENERATION_CANCELED_CODE);
}
export function throwIfJobCanceled(requestId) {
    if (isJobCanceled(requestId))
        throw makeGenerationCanceledError();
}
