Skip to content

Commit

Permalink
fix: error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 18, 2022
1 parent 99e163b commit 73b9ade
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/providers/github.ts
Expand Up @@ -36,9 +36,11 @@ export async function fetchGitHubSponsors(token: string, login: string, type: st
},
}) as any

if (data.errors?.[0]?.type === 'INSUFFICIENT_SCOPES')
if (!data)
throw new Error(`Get no response on requesting ${API}`)
else if (data.errors?.[0]?.type === 'INSUFFICIENT_SCOPES')
throw new Error('Token is missing the `read:user` and/or `read:org` scopes')
else if (data.errors.length)
else if (data.errors?.length)
throw new Error(`GitHub API error:\n${JSON.stringify(data.errors, null, 2)}`)

sponsors.push(
Expand Down

0 comments on commit 73b9ade

Please sign in to comment.