}
+ static _almanacErrorThrow() {
+ throw new DBErrors.UnexpectedResult('did not update almanac');
+ }
+
+
async almanacGetAll(dbCtx) {
const _scope = _fileScope('almanacGetAll');
this.logger.debug(_scope, 'called');
try {
const result = await dbCtx.result(this.statement.almanacUpsert, { event, date: date ?? new Date() });
if (result.rowCount != 1) {
- throw new DBErrors.UnexpectedResult('did not upsert almanac event');
+ this.constructor._almanacErrorThrow();
}
} catch (e) {
this.logger.error(_scope, 'failed', { error: e, event, date });
// Update the last cleanup time
const result = await txCtx.result(this.statement.almanacUpsert, { event: almanacEvent, date: now });
if (result.rowCount != 1) {
- throw new DBErrors.UnexpectedResult('did not update almanac');
+ this.constructor._almanacErrorThrow();
}
this.logger.debug(_scope, 'completed', { scopesRemoved, atLeastMsSinceLast });
// Update the last cleanup time
const result = await txCtx.result(this.statement.almanacUpsert, { event: almanacEvent, date: now });
if (result.rowCount != 1) {
- throw new DBErrors.UnexpectedResult('did not update almanac');
+ this.constructor._almanacErrorThrow();
}
this.logger.debug(_scope, 'completed', { tokensRemoved, codeLifespanSeconds, atLeastMsSinceLast });
}
const almanacResult = await dbCtx.result(this.statement.almanacUpsert, { event: almanacEvent, date: new Date() });
if (almanacResult.rowCount != 1) {
- throw new DBErrors.UnexpectedResult('did not update almanac');
+ this.constructor._almanacErrorThrow();
}
} catch (e) {
this.logger.error(_scope, 'failed', { error: e, ...redeemedData });