From 3c9788647b5141dee80311a431937ab58b9df42f Mon Sep 17 00:00:00 2001 From: Nulo Date: Thu, 4 Jan 2024 16:42:47 -0300 Subject: [PATCH] mostrar path a html debug junto al error --- scraper/scrap.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scraper/scrap.ts b/scraper/scrap.ts index 55d94d2..4d9ae9b 100644 --- a/scraper/scrap.ts +++ b/scraper/scrap.ts @@ -49,7 +49,7 @@ export async function downloadList(path: string) { type ScrapResult = | { type: "skipped" } | { type: "done" } - | { type: "error"; url: string; error: any }; + | { type: "error"; url: string; error: any; debugPath: string }; async function scrap(urlS: string): Promise { let url; try { @@ -87,17 +87,17 @@ async function scrap(urlS: string): Promise { return { type: "done" }; } catch (error) { + const urlHash = createHash("md5").update(urlS).digest("hex"); + const output = join("debug", `${urlHash}.html`); if (DEBUG) { - const urlHash = createHash("md5").update(urlS).digest("hex"); - const output = join("debug", `${urlHash}.html`); await mkdir("debug", { recursive: true }); await writeFile(output, html); - console.error(`wrote html to ${output}`); } return { type: "error", url: urlS, error, + debugPath: output, }; } }