fix: check of rate limit (#229)

* fix: task run

* fix: check of rate limit
This commit is contained in:
Alexandro Castro 2023-09-30 10:15:58 +01:00 • committed by GitHub
parent c8bbf60527
commit af753bf270
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@
.env
.idea
.lock
*.sh

View file

@ -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(
@ -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));