catch and log archive failure to prevent server crash

This commit is contained in:
evanpelle
2024-12-09 13:14:59 -08:00
parent da7637477c
commit d290054e5c
+10 -6
View File
@@ -4,10 +4,14 @@ import { Storage } from '@google-cloud/storage';
const storage = new Storage();
export async function archive(gameRecord: GameRecord) {
console.log(`writing game ${gameRecord.id} to gcs`)
const bucket = storage.bucket("openfront-games");
const file = bucket.file(gameRecord.id);
await file.save(JSON.stringify(GameRecordSchema.parse(gameRecord)), {
contentType: 'application/json'
});
try {
console.log(`writing game ${gameRecord.id} to gcs`)
const bucket = storage.bucket("openfront-games");
const file = bucket.file(gameRecord.id);
await file.save(JSON.stringify(GameRecordSchema.parse(gameRecord)), {
contentType: 'application/json'
});
} catch (error) {
console.log(`error writing to gcs: ${error}`)
}
}