From 45e4625ac3ec66c4d459c0e1c52fd95289f5df99 Mon Sep 17 00:00:00 2001 From: "Shahid N. Shah" Date: Fri, 29 Dec 2023 22:12:43 -0500 Subject: [PATCH] feat: introduce resumable errors --- pattern/ingest/duckdb/notebook.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pattern/ingest/duckdb/notebook.ts b/pattern/ingest/duckdb/notebook.ts index ef3931b9..36879e47 100644 --- a/pattern/ingest/duckdb/notebook.ts +++ b/pattern/ingest/duckdb/notebook.ts @@ -531,6 +531,13 @@ export function ingestSqlRegister(): IngestSqlRegister { }; } +export class IngestResumableError extends Error { + constructor(readonly issue: string, cause?: Error) { + super(issue); + if (cause) this.cause = cause; + } +} + export interface IngestArgs { readonly sqlRegister: IngestSqlRegister; readonly emitDagPuml?: @@ -643,7 +650,11 @@ export async function ingest< " ", ), ); - console.error({ cell, error }); + if (error instanceof IngestResumableError) return "continue"; + + // unless the error is resumable, show error and abort + console.error(`[Non-resumable issue in '${cell}']`, error); + return "abort"; }; rsEE.afterCell = (cell, _result, _ctx) => { registerStateChange(`ENTER(${cell})`, `EXIT(${cell})`);