mirror of
https://github.com/reiyua/github-profile-trophy-reiyua-mirror.git
synced 2026-11-17 06:02:09 +11:00
Add try catch for github api
This commit is contained in:
parent
f88e07535b
commit
135c24e31c
1 changed files with 21 additions and 16 deletions
|
|
@ -63,25 +63,30 @@ export class GithubApiService extends GithubRepository {
|
||||||
this.requestUserIssue(username),
|
this.requestUserIssue(username),
|
||||||
this.requestUserPullRequest(username),
|
this.requestUserPullRequest(username),
|
||||||
]);
|
]);
|
||||||
const [repository, activity, issue, pullRequest] = await promises;
|
try {
|
||||||
const status = [
|
const [repository, activity, issue, pullRequest] = await promises;
|
||||||
repository.status,
|
const status = [
|
||||||
activity.status,
|
repository.status,
|
||||||
issue.status,
|
activity.status,
|
||||||
pullRequest.status,
|
issue.status,
|
||||||
];
|
pullRequest.status,
|
||||||
|
];
|
||||||
|
|
||||||
if (status.includes("rejected")) {
|
if (status.includes("rejected")) {
|
||||||
Logger.error(`Can not find a user with username:' ${username}'`);
|
Logger.error(`Can not find a user with username:' ${username}'`);
|
||||||
|
return new ServiceError("Not found", EServiceKindError.NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new UserInfo(
|
||||||
|
(activity as PromiseFulfilledResult<GitHubUserActivity>).value,
|
||||||
|
(issue as PromiseFulfilledResult<GitHubUserIssue>).value,
|
||||||
|
(pullRequest as PromiseFulfilledResult<GitHubUserPullRequest>).value,
|
||||||
|
(repository as PromiseFulfilledResult<GitHubUserRepository>).value,
|
||||||
|
);
|
||||||
|
} catch {
|
||||||
|
Logger.error(`Error fetching user info for username: ${username}`);
|
||||||
return new ServiceError("Not found", EServiceKindError.NOT_FOUND);
|
return new ServiceError("Not found", EServiceKindError.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new UserInfo(
|
|
||||||
(activity as PromiseFulfilledResult<GitHubUserActivity>).value,
|
|
||||||
(issue as PromiseFulfilledResult<GitHubUserIssue>).value,
|
|
||||||
(pullRequest as PromiseFulfilledResult<GitHubUserPullRequest>).value,
|
|
||||||
(repository as PromiseFulfilledResult<GitHubUserRepository>).value,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async executeQuery<T = unknown>(
|
async executeQuery<T = unknown>(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue