File size: 835 Bytes
6dec997 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import type { ContractIssue, ContractReplay } from "./types.js";
export class ContractError extends Error {
readonly replay: ContractReplay;
readonly issues: ContractIssue[];
constructor(message: string, replay: ContractReplay, issues: ContractIssue[] = []) {
super(message);
this.name = "ContractError";
this.replay = replay;
this.issues = issues;
}
}
export class ContractParseError extends ContractError {
constructor(replay: ContractReplay) {
super("Model response was not valid JSON.", replay);
this.name = "ContractParseError";
}
}
export class ContractValidationError extends ContractError {
constructor(replay: ContractReplay, issues: ContractIssue[]) {
super("Model response did not satisfy the contract schema.", replay, issues);
this.name = "ContractValidationError";
}
}
|