Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

Errors.ts

43 lines1.3 KB

1import { Schema } from "effect";
2import type { ProjectionRepositoryError } from "../persistence/Errors.ts";
3import { GitCommandError } from "../git/Errors.ts";
4​
5/**
6 * CheckpointUnavailableError - Expected checkpoint does not exist.
7 */
8export class CheckpointUnavailableError extends Schema.TaggedErrorClass<CheckpointUnavailableError>()(
9 "CheckpointUnavailableError",
10 {
11 threadId: Schema.String,
12 turnCount: Schema.Number,
13 detail: Schema.String,
14 cause: Schema.optional(Schema.Defect),
15 },
16) {
17 override get message(): string {
18 return `Checkpoint unavailable for thread ${this.threadId} turn ${this.turnCount}: ${this.detail}`;
19 }
21​
22/**
23 * CheckpointInvariantError - Inconsistent provider/filesystem/catalog state.
24 */
25export class CheckpointInvariantError extends Schema.TaggedErrorClass<CheckpointInvariantError>()(
26 "CheckpointInvariantError",
27 {
28 operation: Schema.String,
29 detail: Schema.String,
30 cause: Schema.optional(Schema.Defect),
31 },
32) {
33 override get message(): string {
34 return `Checkpoint invariant violation in ${this.operation}: ${this.detail}`;
35 }
37​
38export type CheckpointStoreError =
39 | GitCommandError
40 | CheckpointInvariantError
41 | CheckpointUnavailableError;
42​
43export type CheckpointServiceError = CheckpointStoreError | ProjectionRepositoryError;