Sfoglia il codice sorgente

Improves generic error messaging

main
Eric Amodio 1 anno fa
parent
commit
b86bdb4fce
12 ha cambiato i file con 48 aggiunte e 51 eliminazioni
  1. +3
    -2
      src/commands/copyCurrentBranch.ts
  2. +2
    -4
      src/commands/openBranchOnRemote.ts
  3. +2
    -4
      src/commands/openBranchesOnRemote.ts
  4. +2
    -5
      src/commands/openCommitOnRemote.ts
  5. +2
    -4
      src/commands/openComparisonOnRemote.ts
  6. +2
    -4
      src/commands/openCurrentBranchOnRemote.ts
  7. +3
    -2
      src/commands/openFileOnRemote.ts
  8. +2
    -4
      src/commands/openRepoOnRemote.ts
  9. +2
    -2
      src/commands/showQuickCommitFile.ts
  10. +1
    -3
      src/commands/toggleFileAnnotations.ts
  11. +2
    -4
      src/commands/toggleLineBlame.ts
  12. +25
    -13
      src/messages.ts

+ 3
- 2
src/commands/copyCurrentBranch.ts Vedi File

@ -1,9 +1,10 @@
import type { TextEditor, Uri } from 'vscode';
import { env, window } from 'vscode';
import { env } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
@ -29,7 +30,7 @@ export class CopyCurrentBranchCommand extends ActiveEditorCommand {
}
} catch (ex) {
Logger.error(ex, 'CopyCurrentBranchCommand');
void window.showErrorMessage('Unable to copy current branch name. See output channel for more details');
void showGenericErrorMessage('Unable to copy current branch name');
}
}
}

+ 2
- 4
src/commands/openBranchOnRemote.ts Vedi File

@ -1,10 +1,10 @@
import type { TextEditor, Uri } from 'vscode';
import { window } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/models/remoteResource';
import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages';
import { CommandQuickPickItem } from '../quickpicks/items/common';
import { ReferencePicker, ReferencesQuickPickIncludes } from '../quickpicks/referencePicker';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
@ -87,9 +87,7 @@ export class OpenBranchOnRemoteCommand extends ActiveEditorCommand {
}));
} catch (ex) {
Logger.error(ex, 'OpenBranchOnRemoteCommand');
void window.showErrorMessage(
'Unable to open branch on remote provider. See output channel for more details',
);
void showGenericErrorMessage('Unable to open branch on remote provider');
}
}
}

+ 2
- 4
src/commands/openBranchesOnRemote.ts Vedi File

@ -1,10 +1,10 @@
import type { TextEditor, Uri } from 'vscode';
import { window } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/models/remoteResource';
import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command, executeCommand } from '../system/command';
import type { CommandContext } from './base';
@ -63,9 +63,7 @@ export class OpenBranchesOnRemoteCommand extends ActiveEditorCommand {
}));
} catch (ex) {
Logger.error(ex, 'OpenBranchesOnRemoteCommand');
void window.showErrorMessage(
'Unable to open branches on remote provider. See output channel for more details',
);
void showGenericErrorMessage('Unable to open branches on remote provider');
}
}
}

+ 2
- 5
src/commands/openCommitOnRemote.ts Vedi File

@ -1,12 +1,11 @@
import type { TextEditor, Uri } from 'vscode';
import { window } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { GitRevision } from '../git/models/reference';
import { RemoteResourceType } from '../git/models/remoteResource';
import { Logger } from '../logger';
import { showFileNotUnderSourceControlWarningMessage } from '../messages';
import { showFileNotUnderSourceControlWarningMessage, showGenericErrorMessage } from '../messages';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command, executeCommand } from '../system/command';
import type { CommandContext } from './base';
@ -106,9 +105,7 @@ export class OpenCommitOnRemoteCommand extends ActiveEditorCommand {
}));
} catch (ex) {
Logger.error(ex, 'OpenCommitOnRemoteCommand');
void window.showErrorMessage(
'Unable to open commit on remote provider. See output channel for more details',
);
void showGenericErrorMessage('Unable to open commit on remote provider');
}
}
}

+ 2
- 4
src/commands/openComparisonOnRemote.ts Vedi File

@ -1,8 +1,8 @@
import { window } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { RemoteResourceType } from '../git/models/remoteResource';
import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages';
import { command, executeCommand } from '../system/command';
import { ResultsCommitsNode } from '../views/nodes/resultsCommitsNode';
import type { CommandContext } from './base';
@ -58,9 +58,7 @@ export class OpenComparisonOnRemoteCommand extends Command {
}));
} catch (ex) {
Logger.error(ex, 'OpenComparisonOnRemoteCommand');
void window.showErrorMessage(
'Unable to open comparison on remote provider. See output channel for more details',
);
void showGenericErrorMessage('Unable to open comparison on remote provider');
}
}
}

+ 2
- 4
src/commands/openCurrentBranchOnRemote.ts Vedi File

@ -1,10 +1,10 @@
import type { TextEditor, Uri } from 'vscode';
import { window } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/models/remoteResource';
import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command, executeCommand } from '../system/command';
import { ActiveEditorCommand, getCommandUri } from './base';
@ -37,9 +37,7 @@ export class OpenCurrentBranchOnRemoteCommand extends ActiveEditorCommand {
}
} catch (ex) {
Logger.error(ex, 'OpenCurrentBranchOnRemoteCommand');
void window.showErrorMessage(
'Unable to open branch on remote provider. See output channel for more details',
);
void showGenericErrorMessage('Unable to open branch on remote provider');
}
}
}

+ 3
- 2
src/commands/openFileOnRemote.ts Vedi File

@ -1,5 +1,5 @@
import type { TextEditor, Uri } from 'vscode';
import { Range, window } from 'vscode';
import { Range } from 'vscode';
import { UriComparer } from '../comparers';
import { BranchSorting, TagSorting } from '../configuration';
import { Commands, GlyphChars } from '../constants';
@ -9,6 +9,7 @@ import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '../git/
import { GitRevision } from '../git/models/reference';
import { RemoteResourceType } from '../git/models/remoteResource';
import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages';
import { ReferencePicker } from '../quickpicks/referencePicker';
import { command, executeCommand } from '../system/command';
import { pad, splitSingle } from '../system/string';
@ -206,7 +207,7 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
}));
} catch (ex) {
Logger.error(ex, 'OpenFileOnRemoteCommand');
void window.showErrorMessage('Unable to open file on remote provider. See output channel for more details');
void showGenericErrorMessage('Unable to open file on remote provider');
}
}
}

+ 2
- 4
src/commands/openRepoOnRemote.ts Vedi File

@ -1,10 +1,10 @@
import type { TextEditor, Uri } from 'vscode';
import { window } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { RemoteResourceType } from '../git/models/remoteResource';
import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages';
import { RepositoryPicker } from '../quickpicks/repositoryPicker';
import { command, executeCommand } from '../system/command';
import type { CommandContext } from './base';
@ -61,9 +61,7 @@ export class OpenRepoOnRemoteCommand extends ActiveEditorCommand {
}));
} catch (ex) {
Logger.error(ex, 'OpenRepoOnRemoteCommand');
void window.showErrorMessage(
'Unable to open repository on remote provider. See output channel for more details',
);
void showGenericErrorMessage('Unable to open repository on remote provider');
}
}
}

+ 2
- 2
src/commands/showQuickCommitFile.ts Vedi File

@ -1,5 +1,5 @@
import type { TextEditor } from 'vscode';
import { Uri, window } from 'vscode';
import { Uri } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { GitUri } from '../git/gitUri';
@ -100,7 +100,7 @@ export class ShowQuickCommitFileCommand extends ActiveEditorCachedCommand {
args.commit = blame.commit;
} catch (ex) {
Logger.error(ex, 'ShowQuickCommitFileDetailsCommand', `getBlameForLine(${blameLine})`);
void window.showErrorMessage('Unable to show commit file details. See output channel for more details');
void showGenericErrorMessage('Unable to show commit file details');
return;
}

+ 1
- 3
src/commands/toggleFileAnnotations.ts Vedi File

@ -137,8 +137,6 @@ async function toggleFileAnnotations
));
} catch (ex) {
Logger.error(ex, 'ToggleFileAnnotationsCommand');
void window.showErrorMessage(
`Unable to toggle file ${args.type} annotations. See output channel for more details`,
);
void showGenericErrorMessage(`Unable to toggle file ${args.type} annotations`);
}
}

+ 2
- 4
src/commands/toggleLineBlame.ts Vedi File

@ -1,8 +1,8 @@
import type { TextEditor, Uri } from 'vscode';
import { window } from 'vscode';
import { Commands } from '../constants';
import type { Container } from '../container';
import { Logger } from '../logger';
import { showGenericErrorMessage } from '../messages';
import { command } from '../system/command';
import { ActiveEditorCommand } from './base';
@ -17,9 +17,7 @@ export class ToggleLineBlameCommand extends ActiveEditorCommand {
await this.container.lineAnnotations.toggle(editor);
} catch (ex) {
Logger.error(ex, 'ToggleLineBlameCommand');
void window.showErrorMessage(
'Unable to toggle line blame annotations. See output channel for more details',
);
void showGenericErrorMessage('Unable to toggle line blame annotations');
}
}
}

+ 25
- 13
src/messages.ts Vedi File

@ -1,8 +1,10 @@
import type { MessageItem } from 'vscode';
import { ConfigurationTarget, env, Uri, window } from 'vscode';
import { configuration, SuppressedMessages } from './configuration';
import { Commands } from './constants';
import type { GitCommit } from './git/models/commit';
import { Logger } from './logger';
import { Logger, LogLevel } from './logger';
import { executeCommand } from './system/command';
export function showCommitHasNoPreviousCommitWarningMessage(commit?: GitCommit): Promise<MessageItem | undefined> {
if (commit == null) {
@ -44,20 +46,30 @@ export async function showDebugLoggingWarningMessage(): Promise {
return result === disable;
}
export async function showGenericErrorMessage(message: string): Promise<MessageItem | undefined> {
const actions: MessageItem[] = [{ title: 'Open Output Channel' }];
const result = await showMessage(
'error',
`${message}. See output channel for more details`,
undefined,
null,
...actions,
);
export async function showGenericErrorMessage(message: string): Promise<void> {
if (Logger.enabled(LogLevel.Error)) {
const result = await showMessage('error', `${message}. See output channel for more details.`, undefined, null, {
title: 'Open Output Channel',
});
if (result !== undefined) {
Logger.showOutputChannel();
if (result != null) {
Logger.showOutputChannel();
}
} else {
const result = await showMessage(
'error',
`${message}. If the error persists, please enable debug logging and try again.`,
undefined,
null,
{
title: 'Enable Debug Logging',
},
);
if (result != null) {
void executeCommand(Commands.EnableDebugLogging);
}
}
return result;
}
export function showFileNotUnderSourceControlWarningMessage(message: string): Promise<MessageItem | undefined> {

Caricamento…
Annulla
Salva