mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 22:26:19 +00:00
mostrar path a html debug junto al error
This commit is contained in:
parent
4f5994a2e1
commit
3c9788647b
1 changed files with 4 additions and 4 deletions
|
@ -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) {
|
||||
if (DEBUG) {
|
||||
const urlHash = createHash("md5").update(urlS).digest("hex");
|
||||
const output = join("debug", `${urlHash}.html`);
|
||||
if (DEBUG) {
|
||||
await mkdir("debug", { recursive: true });
|
||||
await writeFile(output, html);
|
||||
console.error(`wrote html to ${output}`);
|
||||
}
|
||||
return {
|
||||
type: "error",
|
||||
url: urlS,
|
||||
error,
|
||||
debugPath: output,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue