INNER CODE UNIT · TypeScript
tryWrite
totec448-spec/chat-on-steroids · src/main/codex/apply-patch/index.ts:248
const tryWrite = async <T>(work: Promise<T>): Promise<T> => {
try {
return await work;
} catch (error) {
delta.exact = false;
throw error;
}
};
for (const hunk of hunks) {
const affectedPath = hunkPath(hunk);
const resolved = resolveHunkPath(hunk, cwd, resolvePath);
if (hunk.kind === 'add_file') {
await ensurePatchSourceWithinBudget(resolved, true);
const overwrittenContent = await readOptionalFileTextForDelta(resolved, delta);
await tryWrite(writeFileWithMissingParentRetry(resolved, hunk.contents));
delta.changes.push({