feat: add TechLog feature contracts

This commit is contained in:
DongHyeonka
2026-08-15 18:07:12 +09:00
parent 5479101c8c
commit 01ed1e9300
9 changed files with 2787 additions and 0 deletions
@@ -0,0 +1,32 @@
import type { ProblemDetails } from "../../contracts/studio/contract.ts";
export class StudioGatewayError extends Error {
readonly problem: ProblemDetails;
readonly status: number;
readonly code: ProblemDetails["code"];
readonly retryable: boolean;
constructor(problem: ProblemDetails, options?: ErrorOptions) {
super(problem.detail, options);
this.name = "StudioGatewayError";
this.problem = problem;
this.status = problem.status;
this.code = problem.code;
this.retryable = problem.retryable ?? false;
}
}
export function isStudioGatewayError(value: unknown): value is StudioGatewayError {
if (typeof value !== "object" || value === null) return false;
const candidate = value as Partial<StudioGatewayError>;
return (
typeof candidate.message === "string" &&
typeof candidate.status === "number" &&
typeof candidate.code === "string" &&
typeof candidate.retryable === "boolean" &&
typeof candidate.problem === "object" &&
candidate.problem !== null &&
candidate.problem.status === candidate.status &&
candidate.problem.code === candidate.code
);
}