From a5f9d791337358ca2e1cc7d68c8c65fab0bca9e9 Mon Sep 17 00:00:00 2001 From: Kid <44045911+kidonng@users.noreply.github.com> Date: Mon, 4 Oct 2021 13:21:01 +0800 Subject: Meta: Improve lack of token scopes message (#4852) --- source/github-helpers/api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/github-helpers/api.ts') diff --git a/source/github-helpers/api.ts b/source/github-helpers/api.ts index e9ca80af..069f0197 100644 --- a/source/github-helpers/api.ts +++ b/source/github-helpers/api.ts @@ -72,7 +72,7 @@ export async function expectTokenScope(scope: string): Promise { const {headers} = await v3('/'); const tokenScopes = headers.get('X-OAuth-Scopes')!; if (!tokenScopes.split(', ').includes(scope)) { - throw new Error(`The token you provided does not have the \`${scope}\` scope. It only includes \`${tokenScopes}\``); + throw new Error('The token you provided does not have ' + (tokenScopes ? `the \`${scope}\` scope. It only includes \`${tokenScopes}\`.` : 'any scope.')); } } -- cgit v1.2.3