mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
fix: check of rate limit (#229)
* fix: task run * fix: check of rate limit
This commit is contained in:
parent
c8bbf60527
commit
af753bf270
2 changed files with 10 additions and 3 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@
|
||||||
.env
|
.env
|
||||||
.idea
|
.idea
|
||||||
.lock
|
.lock
|
||||||
|
*.sh
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,11 @@ export class GithubApiService extends GithubRepository {
|
||||||
|
|
||||||
private handleError(responseErrors: GithubError[]): ServiceError {
|
private handleError(responseErrors: GithubError[]): ServiceError {
|
||||||
const errors = responseErrors ?? [];
|
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) {
|
if (isRateLimitExceeded) {
|
||||||
throw new ServiceError(
|
throw new ServiceError(
|
||||||
|
|
@ -133,6 +135,10 @@ export class GithubApiService extends GithubRepository {
|
||||||
return response?.data?.data?.user ??
|
return response?.data?.data?.user ??
|
||||||
new ServiceError("not found", EServiceKindError.NOT_FOUND);
|
new ServiceError("not found", EServiceKindError.NOT_FOUND);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
if (error instanceof ServiceError) {
|
||||||
|
Logger.error(error);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
// TODO: Move this to a logger instance later
|
// TODO: Move this to a logger instance later
|
||||||
if (error instanceof Error && error.cause) {
|
if (error instanceof Error && error.cause) {
|
||||||
Logger.error(JSON.stringify(error.cause, null, 2));
|
Logger.error(JSON.stringify(error.cause, null, 2));
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue