Skip to content

feat: speculative more informative error message #1617

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/shared/options/getGitHub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@ export interface GitHub {
}

export async function getGitHub(): Promise<GitHub | undefined> {
const auth = await getGitHubAuthToken();
try {
const auth = await getGitHubAuthToken();

if (!auth.succeeded) {
throw new Error("GitHub authentication failed.", {
cause: auth.error,
if (!auth.succeeded) {
throw new Error("GitHub authentication failed.", {
cause: auth.error,
});
}

const octokit = new Octokit({ auth: auth.token });

return { auth: auth.token, octokit };
} catch (error) {
throw new Error("GitHub authentication failed - is the GitHub CLI installed and are you logged in?", {
cause: error
});
}

const octokit = new Octokit({ auth: auth.token });

return { auth: auth.token, octokit };
}
Loading