Skip to content

Commit

Permalink
Show rate limit error to the user (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela committed Jun 24, 2022
1 parent d640ccc commit bffaf4a
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { RateLimitServiceConfig } from './tokens';
import type { RateLimitApi, RateLimitQueryInput } from '@hive/rate-limit';
import { createTRPCClient } from '@trpc/client';
import { fetch } from 'cross-undici-fetch';
import { HiveError } from '../../../shared/errors';

@Injectable({
global: true,
Expand Down Expand Up @@ -33,7 +34,7 @@ export class RateLimitProvider {
const limit = await this.checkRateLimit(input);

if (limit.limited) {
throw new Error(`Monthly limit for ${input.type} has reached!`);
throw new HiveError(`Monthly limit for ${input.type} has reached!`);
}

return limit;
Expand Down

0 comments on commit bffaf4a

Please sign in to comment.