INNER CODE UNIT · TypeScript

writeLine

totec448-spec/chat-on-steroids · src/main/codex/apply-patch/index.ts:139

function writeLine(out: Writer, line: string): void {
  out.text += `${line}\n`;
}

function messageOf(error: unknown): string {
  return error instanceof Error ? error.message : String(error);
}

/**
 * Rust's `.with_context(|| ...)`: replaces the message the caller will see while keeping the
 * original error reachable as the cause.
 */
async function withContext<T>(work: Promise<T>, context: () => string): Promise<T> {
  try {
    return await work;
  } catch (error) {
    throw new Error(context(), { cause: error });
  }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…