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 / telemetry / hooks / gate / caught / caught.ts
14 lines · 507 BRaw
1import type { Caught } from 'claude-code'
2
3import { REFUSED } from '../refused'
4
5/**
6 * The gate's `.catch`: a gate that threw before going on refuses the call;
7 * a refusal from beneath (a malformed entry) is passed up as it is.
8 *
9 * @param e the entry as the caller passed it
10 * @param next the replay-safe continuation the catch is handed
11 * @returns beneath's own answer replayed, or the refusal
12 */
13export const caught = <E, R>(e: E, next: ((e: E) => R) & Caught) =>
14 next.called ? next(e) : REFUSED