From b45926a4d729c13023f73f8b78c18af9f65b2bcb Mon Sep 17 00:00:00 2001 From: Jamie Magee Date: Wed, 16 Jun 2021 20:40:22 -0700 Subject: [PATCH] remove cache decorator error handling entirely --- lib/util/cache/package/decorator.ts | 57 +++++++++++++---------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/lib/util/cache/package/decorator.ts b/lib/util/cache/package/decorator.ts index 1e94d38455534e8..f7d13f977593695 100644 --- a/lib/util/cache/package/decorator.ts +++ b/lib/util/cache/package/decorator.ts @@ -90,37 +90,32 @@ export function cache({ ttlMinutes = 30, }: CacheParameters): Decorator { return decorate(async ({ args, instance, callback }) => { - try { - let finalNamespace: string; - if (is.string(namespace)) { - finalNamespace = namespace; - } else if (is.function_(namespace)) { - finalNamespace = namespace.apply(instance, args); - } - - let finalKey: string; - if (is.string(key)) { - finalKey = key; - } else if (is.function_(key)) { - finalKey = key.apply(instance, args); - } - - const cachedResult = await packageCache.get( - finalNamespace, - finalKey - ); - - if (cachedResult !== undefined) { - return cachedResult; - } - - const result = await callback(); - - await packageCache.set(finalNamespace, finalKey, result, ttlMinutes); - return result; - } catch (err) /* istanbul ignore next */ { - logger.trace({ err }, 'cache decorate error'); - throw err; + let finalNamespace: string; + if (is.string(namespace)) { + finalNamespace = namespace; + } else if (is.function_(namespace)) { + finalNamespace = namespace.apply(instance, args); } + + let finalKey: string; + if (is.string(key)) { + finalKey = key; + } else if (is.function_(key)) { + finalKey = key.apply(instance, args); + } + + const cachedResult = await packageCache.get( + finalNamespace, + finalKey + ); + + if (cachedResult !== undefined) { + return cachedResult; + } + + const result = await callback(); + + await packageCache.set(finalNamespace, finalKey, result, ttlMinutes); + return result; }); }