Skip to content

Commit

Permalink
Merge pull request #34 from Fgerthoffert/develop
Browse files Browse the repository at this point in the history
Improved error logging when importing sites
  • Loading branch information
Fgerthoffert authored Mar 20, 2020
2 parents d7b8bcb + ae22be2 commit 61f3cb1
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/components/webprojects/importfile/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,35 @@ const importFileWebproject = async (
);
await Promise.all([page.waitForNavigation(), button.click()]);

const errorDetails = await page.$('#siteSettings > div:nth-child(1) > div.container-fluid > div > div > div.row > div > form > div > div > a');
const errorDetails = await page.$(
'#siteSettings > div:nth-child(1) > div.container-fluid > div > div > div.row > div > form > div > div > a',
);
if (errorDetails !== null) {
console.log('ERROR: The project cannot be installed due to a missing dependency (likely a missing module)');
exit();
console.log(
'ERROR: The project cannot be installed due to a missing dependency (likely a missing module)',
);
const errorMsg = await page.evaluate(() => {
const selector = document.querySelector("div[class*='alert-danger']");
if (selector !== null && selector.textContent !== null) {
return selector.textContent.trim().replace(/\s\s+/g, ' ');
}
return '';
});
console.log('ERROR: ' + errorMsg);

const errorContent = await page.evaluate(() => {
const selector = document.querySelector("div[id*='validationErrors'");
if (selector !== null && selector.textContent !== null) {
return selector.textContent.trim().replace(/\s\s+/g, ' ');
}
return '';
});
console.log('ERROR: ' + errorContent);
// console.log(validationError);
// console.log(text);
exit();
}

const importSite = await page.$('button[name="_eventId_processImport"]');
await Promise.all([
page.waitForNavigation({ timeout: 600000 }),
Expand Down

0 comments on commit 61f3cb1

Please sign in to comment.