pg: ignore empty login error message, fixes #58

This commit is contained in:
Ralf Vogler 2023-02-14 10:29:21 +01:00
parent f873d95a89
commit acbfa9156e

View file

@ -58,7 +58,8 @@ try {
await page.click('input[type="submit"]'); await page.click('input[type="submit"]');
page.waitForURL('**/ap/signin**').then(async () => { // check for wrong credentials page.waitForURL('**/ap/signin**').then(async () => { // check for wrong credentials
const error = await page.locator('.a-alert-content').first().innerText(); const error = await page.locator('.a-alert-content').first().innerText();
console.error(error); if (!error.trim.length) return;
console.error('Login error:', error);
notify(`prime-gaming: login: ${error}`); notify(`prime-gaming: login: ${error}`);
await context.close(); // finishes potential recording await context.close(); // finishes potential recording
process.exit(1); process.exit(1);
@ -75,7 +76,7 @@ try {
console.log('Waiting for you to login in the browser.'); console.log('Waiting for you to login in the browser.');
notify('prime-gaming: no longer signed in and not enough options set for automatic login.'); notify('prime-gaming: no longer signed in and not enough options set for automatic login.');
if (cfg.headless) { if (cfg.headless) {
console.log('Please run `node prime-gaming show` to login in the opened browser.'); console.log('Please run `SHOW=1 node prime-gaming` to login in the opened browser.');
await context.close(); // finishes potential recording await context.close(); // finishes potential recording
process.exit(1); process.exit(1);
} }
@ -171,7 +172,7 @@ try {
// await page.screenshot({ path: p, fullPage: true }); // await page.screenshot({ path: p, fullPage: true });
await page.locator(games_sel).screenshot({ path: p }); await page.locator(games_sel).screenshot({ path: p });
} catch (error) { } catch (error) {
console.error(error); // .toString()? console.error('Catch error:', error); // .toString()?
if (error.message && !error.message.includes('Target closed')) // e.g. when killed by Ctrl-C if (error.message && !error.message.includes('Target closed')) // e.g. when killed by Ctrl-C
notify(`prime-gaming failed: ${error.message.split('\n')[0]}`); notify(`prime-gaming failed: ${error.message.split('\n')[0]}`);
} finally { } finally {