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: "skipped" }
| { type: "done" }
| { type: "error"; url: string; error: any };
| { type: "error"; url: string; error: any; debugPath: string };
async function scrap(urlS: string): Promise<ScrapResult> {
let url;
try {
@ -87,17 +87,17 @@ async function scrap(urlS: string): Promise<ScrapResult> {
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,
};
}
}