INNER CODE UNIT · TypeScript
withContext
totec448-spec/chat-on-steroids · src/main/codex/apply-patch/index.ts:151
async function withContext<T>(work: Promise<T>, context: () => string): Promise<T> {
try {
return await work;
} catch (error) {
throw new Error(context(), { cause: error });
}
}
function errorCode(error: unknown): string | undefined {
return typeof error === 'object' && error !== null ? (error as NodeJS.ErrnoException).code : undefined;
}
/** `apply_patch`: applies the patch and writes the result to the given buffers. */
export async function applyPatch(
patch: string,
cwd: string,
stdout: Writer,
stderr: Writer,