♻️ Improve error handling
This commit is contained in:
parent
48d5e2e3c4
commit
46defdb77b
2 changed files with 13 additions and 8 deletions
10
src/index.ts
10
src/index.ts
|
@ -12,17 +12,21 @@ const newPatches: any[] = [];
|
|||
const productData: { [key in Product]?: IProductData } = await model.init();
|
||||
const productDataEntries = Object.entries(productData) as Array<[Product, IProductData]>;
|
||||
|
||||
//Check for new manifest version
|
||||
await Promise.all(productDataEntries.map(async ([product, { manifest, http}]) => {
|
||||
//Check for new manifest version
|
||||
try {
|
||||
const { current} = await getManifest(product);
|
||||
if (current < manifest) {
|
||||
writeLog(`Product ${product} now has a smaller manifest version ${current}, down from ${manifest}.`);
|
||||
return;
|
||||
}
|
||||
if (current > manifest) {
|
||||
} else if (current > manifest) {
|
||||
writeLog(`New manifest version: ${current} instead of ${manifest}`);
|
||||
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
|
||||
//TODO
|
||||
|
|
|
@ -28,7 +28,8 @@ export async function init(): Promise<{ [key in Product]?: IProductData }> {
|
|||
});
|
||||
|
||||
//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 };
|
||||
const queryTemplate = `INSERT INTO \`ssn_versions\` (\`product\`, \`manifest\`, \`http\`) VALUES (?, '-1', '-1');`;
|
||||
const query = mysql.format(queryTemplate, [String(product)]);
|
||||
|
|
Loading…
Reference in a new issue