feat(core-shared/conformance): ConformanceError class
This commit is contained in:
@@ -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");
|
||||
});
|
||||
});
|
||||
13
packages/core-shared/src/conformance/conformance-error.ts
Normal file
13
packages/core-shared/src/conformance/conformance-error.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user