Skip to content

Commit 3d18a1e

Browse files
committed
wrap in try catch
1 parent 32cfee0 commit 3d18a1e

File tree

1 file changed

+38
-23
lines changed

1 file changed

+38
-23
lines changed

templates/cli/lib/commands/push.js.twig

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,37 +1793,52 @@ const checkAndApplyTablesDBChanges = async () => {
17931793
// Apply deletions first
17941794
let needsResync = false;
17951795
for (const db of toDelete) {
1796-
log(`Deleting database ${db.name} ( ${db.$id} ) ...`);
1797-
await tablesDBDelete({
1798-
databaseId: db.$id,
1799-
parseOutput: false
1800-
});
1801-
success(`Deleted ${db.name} ( ${db.$id} )`);
1802-
needsResync = true;
1796+
try {
1797+
log(`Deleting database ${db.name} ( ${db.$id} ) ...`);
1798+
await tablesDBDelete({
1799+
databaseId: db.$id,
1800+
parseOutput: false
1801+
});
1802+
success(`Deleted ${db.name} ( ${db.$id} )`);
1803+
needsResync = true;
1804+
} catch (e) {
1805+
error(`Failed to delete database ${db.name} ( ${db.$id} ): ${e.message}`);
1806+
throw new Error(`Database sync failed during deletion of ${db.$id}. Some changes may have been applied.`);
1807+
}
18031808
}
18041809

18051810
// Apply creations
18061811
for (const db of toCreate) {
1807-
log(`Creating database ${db.name} ( ${db.$id} ) ...`);
1808-
await tablesDBCreate({
1809-
databaseId: db.$id,
1810-
name: db.name,
1811-
enabled: db.enabled,
1812-
parseOutput: false
1813-
});
1814-
success(`Created ${db.name} ( ${db.$id} )`);
1812+
try {
1813+
log(`Creating database ${db.name} ( ${db.$id} ) ...`);
1814+
await tablesDBCreate({
1815+
databaseId: db.$id,
1816+
name: db.name,
1817+
enabled: db.enabled,
1818+
parseOutput: false
1819+
});
1820+
success(`Created ${db.name} ( ${db.$id} )`);
1821+
} catch (e) {
1822+
error(`Failed to create database ${db.name} ( ${db.$id} ): ${e.message}`);
1823+
throw new Error(`Database sync failed during creation of ${db.$id}. Some changes may have been applied.`);
1824+
}
18151825
}
18161826

18171827
// Apply updates
18181828
for (const db of toUpdate) {
1819-
log(`Updating database ${db.name} ( ${db.$id} ) ...`);
1820-
await tablesDBUpdate({
1821-
databaseId: db.$id,
1822-
name: db.name,
1823-
enabled: db.enabled,
1824-
parseOutput: false
1825-
});
1826-
success(`Updated ${db.name} ( ${db.$id} )`);
1829+
try {
1830+
log(`Updating database ${db.name} ( ${db.$id} ) ...`);
1831+
await tablesDBUpdate({
1832+
databaseId: db.$id,
1833+
name: db.name,
1834+
enabled: db.enabled,
1835+
parseOutput: false
1836+
});
1837+
success(`Updated ${db.name} ( ${db.$id} )`);
1838+
} catch (e) {
1839+
error(`Failed to update database ${db.name} ( ${db.$id} ): ${e.message}`);
1840+
throw new Error(`Database sync failed during update of ${db.$id}. Some changes may have been applied.`);
1841+
}
18271842
}
18281843

18291844
return { applied: true, resyncNeeded: needsResync };

0 commit comments

Comments
 (0)