UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

35 lines (34 loc) • 1.22 kB
export class ForgeError extends Error { code; constructor(code, message) { super(message); this.code = code; this.name = "ForgeError"; } } const MESSAGES = { auth: "Sign in to the forge or renew its credentials.", "not-found": "The forge repository or issue was not found.", forbidden: "The forge denied access to this operation.", "rate-limited": "The forge rate limit was reached. Try again later.", unavailable: "The forge did not complete the request.", conflict: "The forge reported a conflict.", invalid: "The forge rejected the request.", }; /** The response and subprocess diagnostics may contain credentials or issue content. */ export function forgeFailure(status, rateLimited = false) { let code = "unavailable"; if (status === 429 || rateLimited) code = "rate-limited"; else if (status === 401) code = "auth"; else if (status === 403) code = "forbidden"; else if (status === 404 || status === 410) code = "not-found"; else if (status === 409) code = "conflict"; else if (status >= 400 && status < 500) code = "invalid"; return new ForgeError(code, MESSAGES[code]); }