feat: catch all errors
This commit is contained in:
@ -3,12 +3,17 @@ import logger from "../logger";
|
||||
import * as twitch from "../website/twitch";
|
||||
import * as constants from "../constants";
|
||||
|
||||
async function spawn(context: BrowserContext, targetUrl: string) {
|
||||
const spawnId = btoa(Math.random().toString()).substring(4,10);
|
||||
async function spawn(context: BrowserContext, targetUrl: string, spawnId: string = "unknown") {
|
||||
const server = constants.REFLECT4_SERVERS[Math.floor(Math.random() * constants.REFLECT4_SERVERS.length)];
|
||||
logger.debug(`[${spawnId}] Using reflect4 server: ${server}`);
|
||||
const page = await context.newPage();
|
||||
await page.goto(server);
|
||||
await page.setViewportSize({width: 640, height: 360});
|
||||
try {
|
||||
await page.goto(server);
|
||||
} catch (e) {
|
||||
logger.error(`[${spawnId}] Error while navigating to proxy website: ${e}`);
|
||||
throw e;
|
||||
}
|
||||
let targetInput: Locator | null = null;
|
||||
const allInput = await page.locator("input").all();
|
||||
for (const input of allInput) {
|
||||
@ -20,7 +25,7 @@ async function spawn(context: BrowserContext, targetUrl: string) {
|
||||
}
|
||||
if (!targetInput) {
|
||||
logger.error(`[${spawnId}] Failed to find input field for URL input`);
|
||||
return;
|
||||
throw new Error(`Failed to find input field for URL input`);
|
||||
}
|
||||
await targetInput.fill(targetUrl);
|
||||
await targetInput.press("Enter");
|
||||
|
||||
Reference in New Issue
Block a user