From b07ede0edac67b33acdb1b82f5f08c4b8703d396 Mon Sep 17 00:00:00 2001 From: Jay McDoniel Date: Thu, 6 Jul 2023 12:48:34 -0700 Subject: [PATCH] feat: make method for getting error message ref: #1388 --- src/throttler.guard.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/throttler.guard.ts b/src/throttler.guard.ts index 429fa6d62..886b3d13d 100644 --- a/src/throttler.guard.ts +++ b/src/throttler.guard.ts @@ -171,12 +171,18 @@ export class ThrottlerGuard implements CanActivate { * the method. * @throws {ThrottlerException} */ - // eslint-disable-next-line @typescript-eslint/no-unused-vars - protected throwThrottlingException( + protected async throwThrottlingException( context: ExecutionContext, throttlerLimitDetail: ThrottlerLimitDetail, - ): void { - throw new ThrottlerException(this.errorMessage); + ): Promise { + throw new ThrottlerException(await this.getErrorMessage(context, throttlerLimitDetail)); + } + + protected async getErrorMessage( + _context: ExecutionContext, + _throttlerLimitDetail: ThrottlerLimitDetail, + ): Promise { + return this.errorMessage; } private async resolveValue(