Centralize best-effort deletes: log errors and continue review flow.
All cleanup deletes now use runBestEffort so Gitea delete failures never abort posting the new review. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { log } from "../logging/logger.js";
|
||||
|
||||
/** Run a cleanup step; log failures and continue the review flow. */
|
||||
export async function runBestEffort(input: {
|
||||
operation: string;
|
||||
correlationId?: string;
|
||||
context?: Record<string, unknown>;
|
||||
fn: () => Promise<void>;
|
||||
}): Promise<void> {
|
||||
try {
|
||||
await input.fn();
|
||||
log("info", `${input.operation} succeeded`, {
|
||||
correlation_id: input.correlationId,
|
||||
...input.context
|
||||
});
|
||||
} catch (error) {
|
||||
log("warn", `${input.operation} failed (continuing)`, {
|
||||
correlation_id: input.correlationId,
|
||||
...input.context,
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user