fix: return empty empty str on error
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { chromium, Browser, Page, BrowserContext } from 'playwright';
|
import { chromium, Browser, BrowserContext, Page } from 'playwright';
|
||||||
|
|
||||||
export interface GetPageSourceOptions {
|
export interface GetPageSourceOptions {
|
||||||
wait?: number;
|
wait?: number;
|
||||||
@@ -46,9 +46,10 @@ export async function getPageSource(
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error while getting page source: ', error);
|
console.error('Error while getting page source: ', error);
|
||||||
|
return ''; // Explicitly return empty string on error
|
||||||
} finally {
|
} finally {
|
||||||
if (page) await page.close();
|
if (page) await page.close();
|
||||||
if (context) await context.close();
|
if (context) await context.close();
|
||||||
if (browser) await browser.close();
|
if (browser) await browser.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user