♻️ Improve error handling

This commit is contained in:
C-3PO 2018-11-09 02:59:00 +01:00
parent 48d5e2e3c4
commit 46defdb77b
Signed by: c3po
GPG key ID: 62993C4BB4D86F24
2 changed files with 13 additions and 8 deletions

View file

@ -12,17 +12,21 @@ const newPatches: any[] = [];
const productData: { [key in Product]?: IProductData } = await model.init(); const productData: { [key in Product]?: IProductData } = await model.init();
const productDataEntries = Object.entries(productData) as Array<[Product, IProductData]>; const productDataEntries = Object.entries(productData) as Array<[Product, IProductData]>;
//Check for new manifest version
await Promise.all(productDataEntries.map(async ([product, { manifest, http}]) => { await Promise.all(productDataEntries.map(async ([product, { manifest, http}]) => {
//Check for new manifest version //Check for new manifest version
try {
const { current} = await getManifest(product); const { current} = await getManifest(product);
if (current < manifest) { if (current < manifest) {
writeLog(`Product ${product} now has a smaller manifest version ${current}, down from ${manifest}.`); writeLog(`Product ${product} now has a smaller manifest version ${current}, down from ${manifest}.`);
return; } else if (current > manifest) {
}
if (current > manifest) {
writeLog(`New manifest version: ${current} instead of ${manifest}`); writeLog(`New manifest version: ${current} instead of ${manifest}`);
model.updateManifestVersion(product, current); model.updateManifestVersion(product, current);
} }
} catch (error) {
writeLog(`Could not get manifest for ${product} (previous version was ${manifest}), error message: ${String(error)}`);
return;
}
//Check for new HTTP version //Check for new HTTP version
//TODO //TODO

View file

@ -28,7 +28,8 @@ export async function init(): Promise<{ [key in Product]?: IProductData }> {
}); });
//If row does not exist, INSERT into table //If row does not exist, INSERT into table
await Promise.all(products.filter((product) => output[product] === undefined).map(function(product) { const missingProducts = products.filter((product) => output[product] === undefined);
await Promise.all(missingProducts.map(function(product) {
output[product] = { http: -1, manifest: -1 }; output[product] = { http: -1, manifest: -1 };
const queryTemplate = `INSERT INTO \`ssn_versions\` (\`product\`, \`manifest\`, \`http\`) VALUES (?, '-1', '-1');`; const queryTemplate = `INSERT INTO \`ssn_versions\` (\`product\`, \`manifest\`, \`http\`) VALUES (?, '-1', '-1');`;
const query = mysql.format(queryTemplate, [String(product)]); const query = mysql.format(queryTemplate, [String(product)]);