Skip to content

Commit

Permalink
feat: try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
zugdev committed Jan 25, 2025
1 parent 502c2d5 commit 3ccb1ac
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/directory/get-partner-avatars.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { GitHubOrganization, octokit } from "./directory";

export async function getPartnerAvatars(ownerName: string): Promise<{ownerName: string, avatar_url?: string}> {
const orgResp: GitHubOrganization[] = await octokit.paginate({
method: "GET",
url: `/orgs/${ownerName}`
});
try {
const orgResp: GitHubOrganization[] = await octokit.paginate({
method: "GET",
url: `/orgs/${ownerName}`
});

const org = orgResp.find((org) => org.login === ownerName);
const org = orgResp.find((org) => org.login === ownerName);

return {ownerName, avatar_url: org ? org.avatar_url : undefined};
return {ownerName, avatar_url: org ? org.avatar_url : undefined};
} catch (error) {
console.error(`Error fetching organization for ${ownerName}:`, error);
return {ownerName, avatar_url: undefined};
}
}

0 comments on commit 3ccb1ac

Please sign in to comment.