Skip to content

Commit

Permalink
fix: check of rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcastrodev committed Sep 30, 2023
1 parent 0728fac commit 3a3622e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 70 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
.env
.idea
.lock
*.sh
67 changes: 0 additions & 67 deletions deno.lock

This file was deleted.

12 changes: 9 additions & 3 deletions src/Services/GithubApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ export class GithubApiService extends GithubRepository {

private handleError(responseErrors: GithubError[]): ServiceError {
const errors = responseErrors ?? [];
const isRateLimitExceeded = (errors ?? []).some((error) => {
error.type.includes(EServiceKindError.RATE_LIMIT);
});

const isRateLimitExceeded = errors.some((error) =>
error.type.includes(EServiceKindError.RATE_LIMIT) ||
error.message.includes("rate limit")
);

if (isRateLimitExceeded) {
throw new ServiceError(
Expand Down Expand Up @@ -133,6 +135,10 @@ export class GithubApiService extends GithubRepository {
return response?.data?.data?.user ??
new ServiceError("not found", EServiceKindError.NOT_FOUND);
} catch (error) {
if (error instanceof ServiceError) {
Logger.error(error);
return error;
}
// TODO: Move this to a logger instance later
if (error instanceof Error && error.cause) {
Logger.error(JSON.stringify(error.cause, null, 2));
Expand Down

0 comments on commit 3a3622e

Please sign in to comment.