feat(core-shared/conformance): ConformanceError class

This commit is contained in:
2026-05-12 22:43:15 +02:00
parent 1d8b30045a
commit 49bd7e0782
2 changed files with 30 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import { describe, it, expect } from "vitest";
import { ConformanceError } from "@/conformance/conformance-error";
describe("ConformanceError", () => {
it("extends Error with the standard shape", () => {
const err = new ConformanceError("auth.signIn: missing __instrumented brand");
expect(err).toBeInstanceOf(Error);
expect(err).toBeInstanceOf(ConformanceError);
expect(err.message).toBe("auth.signIn: missing __instrumented brand");
expect(err.name).toBe("ConformanceError");
});
it("preserves a stack trace", () => {
const err = new ConformanceError("test");
expect(typeof err.stack).toBe("string");
});
});

View File

@@ -0,0 +1,13 @@
/**
* Thrown by `assertFeatureConformance` when a binding does not match the
* manifest's declared shape. The boot assertion lets this propagate
* synchronously so `pnpm dev` refuses to start on drift.
*/
export class ConformanceError extends Error {
constructor(message: string) {
super(message);
this.name = "ConformanceError";
// Maintain a proper prototype chain across down-compilation.
Object.setPrototypeOf(this, ConformanceError.prototype);
}
}