diff --git a/extensions/github-authentication/src/github.ts b/extensions/github-authentication/src/github.ts index 504af0384d6..cf0b65424e6 100644 --- a/extensions/github-authentication/src/github.ts +++ b/extensions/github-authentication/src/github.ts @@ -209,7 +209,7 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid return session; } catch (e) { // If login was cancelled, do not notify user. - if (e.message === 'Cancelled') { + if (e === 'Cancelled') { /* __GDPR__ "loginCancelled" : { } */ diff --git a/src/vs/workbench/services/authentication/browser/authenticationService.ts b/src/vs/workbench/services/authentication/browser/authenticationService.ts index 8652c0c8dd2..07fe8663867 100644 --- a/src/vs/workbench/services/authentication/browser/authenticationService.ts +++ b/src/vs/workbench/services/authentication/browser/authenticationService.ts @@ -713,19 +713,19 @@ export class AuthenticationService extends Disposable implements IAuthentication } async getSessions(id: string, scopes?: string[], activateImmediate: boolean = false): Promise> { - try { - const authProvider = this._authenticationProviders.get(id) || await this.tryActivateProvider(id, activateImmediate); + const authProvider = this._authenticationProviders.get(id) || await this.tryActivateProvider(id, activateImmediate); + if (authProvider) { return await authProvider.getSessions(scopes); - } catch (_) { + } else { throw new Error(`No authentication provider '${id}' is currently registered.`); } } async createSession(id: string, scopes: string[], activateImmediate: boolean = false): Promise { - try { - const authProvider = this._authenticationProviders.get(id) || await this.tryActivateProvider(id, activateImmediate); + const authProvider = this._authenticationProviders.get(id) || await this.tryActivateProvider(id, activateImmediate); + if (authProvider) { return await authProvider.createSession(scopes); - } catch (_) { + } else { throw new Error(`No authentication provider '${id}' is currently registered.`); } }