openclaw / src /plugins /runtime /runtime-llm-error.test.ts
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
4c76b0d verified
Raw
History Blame Contribute Delete
882 Bytes
import { describe, expect, it } from "vitest";
import { createLlmCompleteError } from "./runtime-llm-error.js";
describe("createLlmCompleteError", () => {
it("creates a plain Error with the stable completion error fields and cause", () => {
const cause = new Error("provider failed");
const error = createLlmCompleteError("LLM_COMPLETION_FAILED", "Completion failed.", cause);
expect(Object.getPrototypeOf(error)).toBe(Error.prototype);
expect(error).toMatchObject({
name: "LlmCompleteError",
code: "LLM_COMPLETION_FAILED",
message: "Completion failed.",
cause,
});
expect(error.cause).toBe(cause);
});
it("omits the cause property when no cause is supplied", () => {
const error = createLlmCompleteError("LLM_COMPLETION_ABORTED", "Completion aborted.");
expect(Object.hasOwn(error, "cause")).toBe(false);
});
});