Skip to content

Commit 948405e

Browse files
committed
Fixes #1897 avoid messages on 500 errors
Hides unexpected GitHub errors for now Refs #1893
1 parent 7a5191f commit 948405e

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [Unreleased]
8+
9+
### Fixed
10+
11+
- Fixes [#1897](https://github.com/gitkraken/vscode-gitlens/issues/1897) - Repeated GitHub errors when offline
12+
713
## [12.0.2] - 2022-03-09
814

915
### Added

src/plus/github/github.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1764,11 +1764,13 @@ export class GitHubApi implements Disposable {
17641764
}
17651765
}
17661766

1767-
void window.showErrorMessage(`GitHub request failed: ${ex.errors?.[0]?.message ?? ex.message}`, 'OK');
1767+
if (Logger.isDebugging) {
1768+
void window.showErrorMessage(`GitHub request failed: ${ex.errors?.[0]?.message ?? ex.message}`);
1769+
}
17681770
} else if (ex instanceof RequestError) {
17691771
this.handleRequestError(ex, token);
1770-
} else {
1771-
void window.showErrorMessage(`GitHub request failed: ${ex.message}`, 'OK');
1772+
} else if (Logger.isDebugging) {
1773+
void window.showErrorMessage(`GitHub request failed: ${ex.message}`);
17721774
}
17731775

17741776
throw ex;
@@ -1785,8 +1787,8 @@ export class GitHubApi implements Disposable {
17851787
} catch (ex) {
17861788
if (ex instanceof RequestError) {
17871789
this.handleRequestError(ex, token);
1788-
} else {
1789-
void window.showErrorMessage(`GitHub request failed: ${ex.message}`, 'OK');
1790+
} else if (Logger.isDebugging) {
1791+
void window.showErrorMessage(`GitHub request failed: ${ex.message}`);
17901792
}
17911793

17921794
throw ex;
@@ -1824,11 +1826,11 @@ export class GitHubApi implements Disposable {
18241826
'OK',
18251827
);
18261828
}
1827-
break;
1829+
return;
18281830
case 502: // Bad Gateway
18291831
// GitHub seems to return this status code for timeouts
18301832
if (ex.message.includes('timeout')) {
1831-
void window.showErrorMessage('GitHub request timed out', 'OK');
1833+
void window.showErrorMessage('GitHub request timed out');
18321834
return;
18331835
}
18341836
break;
@@ -1837,10 +1839,11 @@ export class GitHubApi implements Disposable {
18371839
break;
18381840
}
18391841

1840-
void window.showErrorMessage(
1841-
`GitHub request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,
1842-
'OK',
1843-
);
1842+
if (Logger.isDebugging) {
1843+
void window.showErrorMessage(
1844+
`GitHub request failed: ${(ex.response as any)?.errors?.[0]?.message ?? ex.message}`,
1845+
);
1846+
}
18441847
}
18451848

18461849
private handleException<T>(ex: unknown | Error, cc: LogCorrelationContext | undefined, defaultValue: T): T {
@@ -1869,7 +1872,7 @@ export class GitHubApi implements Disposable {
18691872
this._onDidReauthenticate.fire();
18701873
}
18711874
} else {
1872-
void window.showErrorMessage(ex.message, 'OK');
1875+
void window.showErrorMessage(ex.message);
18731876
}
18741877
}
18751878
}

0 commit comments

Comments
 (0)