Skip to content

Commit

Permalink
Fixes #1897 avoid messages on 500 errors
Browse files Browse the repository at this point in the history
Hides unexpected GitHub errors for now
Refs #1893
  • Loading branch information
eamodio committed Mar 25, 2022
1 parent 04dab59 commit ba524d2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
27 changes: 15 additions & 12 deletions src/plus/github/github.ts
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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<T>(ex: unknown | Error, cc: LogCorrelationContext | undefined, defaultValue: T): T {
Expand Down Expand Up @@ -1869,7 +1872,7 @@ export class GitHubApi implements Disposable {
this._onDidReauthenticate.fire();
}
} else {
void window.showErrorMessage(ex.message, 'OK');
void window.showErrorMessage(ex.message);
}
}
}
Expand Down

0 comments on commit ba524d2

Please sign in to comment.