mostrar path a html debug junto al error

This commit is contained in:
Cat /dev/Nulo 2024-01-04 16:42:47 -03:00
parent 4f5994a2e1
commit 3c9788647b

View file

@ -49,7 +49,7 @@ export async function downloadList(path: string) {
type ScrapResult = type ScrapResult =
| { type: "skipped" } | { type: "skipped" }
| { type: "done" } | { type: "done" }
| { type: "error"; url: string; error: any }; | { type: "error"; url: string; error: any; debugPath: string };
async function scrap(urlS: string): Promise<ScrapResult> { async function scrap(urlS: string): Promise<ScrapResult> {
let url; let url;
try { try {
@ -87,17 +87,17 @@ async function scrap(urlS: string): Promise<ScrapResult> {
return { type: "done" }; return { type: "done" };
} catch (error) { } catch (error) {
if (DEBUG) {
const urlHash = createHash("md5").update(urlS).digest("hex"); const urlHash = createHash("md5").update(urlS).digest("hex");
const output = join("debug", `${urlHash}.html`); const output = join("debug", `${urlHash}.html`);
if (DEBUG) {
await mkdir("debug", { recursive: true }); await mkdir("debug", { recursive: true });
await writeFile(output, html); await writeFile(output, html);
console.error(`wrote html to ${output}`);
} }
return { return {
type: "error", type: "error",
url: urlS, url: urlS,
error, error,
debugPath: output,
}; };
} }
} }