spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / sec-default / tests / fixtures / caught / uncalled.ts
26 lines · 882 BRaw
1import type { TargetTier } from 'claude-code'
2
3/**
4 * A failure handler's `next` for a hook that had not called it: the call
5 * runs the links beneath, `to` at `append` the run past the user tier.
6 *
7 * Continued at any other tier it rejects, naming the tier.
8 *
9 * @param beneath what the run through every tier settles to
10 * @param past what the run past the user tier settles to
11 * @param tier the tier of whoever raised the dispatch
12 * @returns the stand-in
13 */
14export const uncalled = <R>(beneath: R, past: R, tier: unknown = 'user') =>
15 Object.assign((_e: unknown) => Promise.resolve(beneath), {
16 to(_e: unknown, at: TargetTier) {
17 const isPastUsers = at === 'append'
18
19 return isPastUsers
20 ? Promise.resolve(past)
21 : Promise.reject(new Error(`continued at ${at}`))
22 },
23 called: false,
24 error: { kind: 'throw' },
25 origin: { tier },
26 })