Add try catch to handler

This commit is contained in:
Thomas Avery 2024-11-01 16:07:18 -05:00
parent 630eb14686
commit c6ce0c1766
No known key found for this signature in database
GPG Key ID: 44A02A0410B0F429
1 changed files with 15 additions and 7 deletions

View File

@ -30,15 +30,23 @@ export class DefaultUserAsymmetricKeysRegenerationService
) {}
async handleUserAsymmetricKeysRegeneration(userId: UserId): Promise<void> {
const privateKeyRegenerationFlag = await this.configService.getFeatureFlag(
FeatureFlag.PrivateKeyRegeneration,
);
try {
const privateKeyRegenerationFlag = await this.configService.getFeatureFlag(
FeatureFlag.PrivateKeyRegeneration,
);
if (privateKeyRegenerationFlag) {
const shouldRegenerate = await this.shouldRegenerate(userId);
if (shouldRegenerate) {
await this.regenerateUserAsymmetricKeys(userId);
if (privateKeyRegenerationFlag) {
const shouldRegenerate = await this.shouldRegenerate(userId);
if (shouldRegenerate) {
await this.regenerateUserAsymmetricKeys(userId);
}
}
} catch (error) {
this.logService.error(
"[UserAsymmetricKeyRegeneration] User Key regeneration error: " +
error +
" Skipping regeneration for the user.",
);
}
}