diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e52634..f8083a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [Unreleased] + +### Fixed + +- Fixes [#1897](https://github.com/gitkraken/vscode-gitlens/issues/1897) - Repeated GitHub errors when offline + ## [12.0.2] - 2022-03-09 ### Added diff --git a/src/plus/github/github.ts b/src/plus/github/github.ts index ca65af9..a2859b6 100644 --- a/src/plus/github/github.ts +++ b/src/plus/github/github.ts @@ -1764,11 +1764,13 @@ export class GitHubApi implements Disposable { } } - void window.showErrorMessage(`GitHub request failed: ${ex.errors?.[0]?.message ?? ex.message}`, 'OK'); + if (Logger.isDebugging) { + void window.showErrorMessage(`GitHub request failed: ${ex.errors?.[0]?.message ?? ex.message}`); + } } else if (ex instanceof RequestError) { this.handleRequestError(ex, token); - } else { - void window.showErrorMessage(`GitHub request failed: ${ex.message}`, 'OK'); + } else if (Logger.isDebugging) { + void window.showErrorMessage(`GitHub request failed: ${ex.message}`); } throw ex; @@ -1785,8 +1787,8 @@ export class GitHubApi implements Disposable { } catch (ex) { if (ex instanceof RequestError) { this.handleRequestError(ex, token); - } else { - void window.showErrorMessage(`GitHub request failed: ${ex.message}`, 'OK'); + } else if (Logger.isDebugging) { + void window.showErrorMessage(`GitHub request failed: ${ex.message}`); } throw ex; @@ -1824,11 +1826,11 @@ export class GitHubApi implements Disposable { 'OK', ); } - break; + return; case 502: // Bad Gateway // GitHub seems to return this status code for timeouts if (ex.message.includes('timeout')) { - void window.showErrorMessage('GitHub request timed out', 'OK'); + void window.showErrorMessage('GitHub request timed out'); return; } break; @@ -1837,10 +1839,11 @@ export class GitHubApi implements Disposable { break; } - void window.showErrorMessage( - `GitHub request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`, - 'OK', - ); + if (Logger.isDebugging) { + void window.showErrorMessage( + `GitHub request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`, + ); + } } private handleException(ex: unknown | Error, cc: LogCorrelationContext | undefined, defaultValue: T): T { @@ -1869,7 +1872,7 @@ export class GitHubApi implements Disposable { this._onDidReauthenticate.fire(); } } else { - void window.showErrorMessage(ex.message, 'OK'); + void window.showErrorMessage(ex.message); } } }