Skip to content

Commit 7ab0920

Browse files
committed
chore: remove redundant try/catch
1 parent c6f65a5 commit 7ab0920

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

docs/snippets/idempotency/advancedBringYourOwnPersistenceLayer.ts

+12-16
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,19 @@ class MomentoCachePersistenceLayer extends BasePersistenceLayer {
9494
}
9595
}
9696

97-
try {
98-
const ttl = record.expiryTimestamp
99-
? Math.floor(new Date(record.expiryTimestamp * 1000).getTime() / 1000) -
100-
Math.floor(new Date().getTime() / 1000)
101-
: this.getExpiresAfterSeconds();
102-
103-
const response = await (
104-
await this.#getClient()
105-
).dictionarySetFields(this.#cacheName, record.idempotencyKey, item, {
106-
ttl: CollectionTtl.of(ttl).withNoRefreshTtlOnUpdates(),
107-
});
97+
const ttl = record.expiryTimestamp
98+
? Math.floor(new Date(record.expiryTimestamp * 1000).getTime() / 1000) -
99+
Math.floor(new Date().getTime() / 1000)
100+
: this.getExpiresAfterSeconds();
108101

109-
if (response instanceof CacheDictionarySetFields.Error) {
110-
throw new Error(`Unable to put item: ${response.errorCode()}`);
111-
}
112-
} catch (error) {
113-
throw error;
102+
const response = await (
103+
await this.#getClient()
104+
).dictionarySetFields(this.#cacheName, record.idempotencyKey, item, {
105+
ttl: CollectionTtl.of(ttl).withNoRefreshTtlOnUpdates(),
106+
});
107+
108+
if (response instanceof CacheDictionarySetFields.Error) {
109+
throw new Error(`Unable to put item: ${response.errorCode()}`);
114110
}
115111
}
116112

0 commit comments

Comments
 (0)