Browse Source

Consolidates error messaging to show output channel button

main
Eric Amodio 6 years ago
parent
commit
f01a8b7430
33 changed files with 91 additions and 45 deletions
  1. +2
    -1
      src/commands/clearFileAnnotations.ts
  2. +2
    -1
      src/commands/closeUnchangedFiles.ts
  3. +3
    -2
      src/commands/copyMessageToClipboard.ts
  4. +3
    -2
      src/commands/copyShaToClipboard.ts
  5. +3
    -2
      src/commands/diffBranchWithBranch.ts
  6. +2
    -1
      src/commands/diffDirectory.ts
  7. +1
    -1
      src/commands/diffLineWithPrevious.ts
  8. +1
    -1
      src/commands/diffLineWithWorking.ts
  9. +3
    -2
      src/commands/diffWith.ts
  10. +1
    -1
      src/commands/diffWithNext.ts
  11. +1
    -1
      src/commands/diffWithPrevious.ts
  12. +1
    -1
      src/commands/diffWithRevision.ts
  13. +1
    -1
      src/commands/diffWithWorking.ts
  14. +2
    -1
      src/commands/externalDiff.ts
  15. +2
    -1
      src/commands/openChangedFiles.ts
  16. +1
    -1
      src/commands/openFileRevision.ts
  17. +3
    -2
      src/commands/openInRemote.ts
  18. +3
    -2
      src/commands/openWorkingFile.ts
  19. +2
    -1
      src/commands/showCommitSearch.ts
  20. +3
    -2
      src/commands/showLastQuickPick.ts
  21. +2
    -1
      src/commands/showQuickBranchHistory.ts
  22. +2
    -2
      src/commands/showQuickCommitDetails.ts
  23. +1
    -1
      src/commands/showQuickCommitFileDetails.ts
  24. +3
    -2
      src/commands/showQuickCurrentBranchHistory.ts
  25. +1
    -1
      src/commands/showQuickFileHistory.ts
  26. +2
    -1
      src/commands/showQuickRepoStatus.ts
  27. +2
    -1
      src/commands/showQuickStashList.ts
  28. +2
    -1
      src/commands/stashApply.ts
  29. +2
    -1
      src/commands/stashDelete.ts
  30. +2
    -1
      src/commands/stashSave.ts
  31. +2
    -1
      src/git/remotes/provider.ts
  32. +6
    -0
      src/logger.ts
  33. +24
    -5
      src/messages.ts

+ 2
- 1
src/commands/clearFileAnnotations.ts View File

@ -3,6 +3,7 @@ import { TextEditor, TextEditorEdit, Uri, window } from 'vscode';
import { UriComparer } from '../comparers'; import { UriComparer } from '../comparers';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { Commands, EditorCommand } from './common'; import { Commands, EditorCommand } from './common';
export class ClearFileAnnotationsCommand extends EditorCommand { export class ClearFileAnnotationsCommand extends EditorCommand {
@ -26,7 +27,7 @@ export class ClearFileAnnotationsCommand extends EditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ClearFileAnnotationsCommand'); Logger.error(ex, 'ClearFileAnnotationsCommand');
return window.showErrorMessage(`Unable to clear file annotations. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to clear file annotations');
} }
} }
} }

+ 2
- 1
src/commands/closeUnchangedFiles.ts View File

@ -4,6 +4,7 @@ import { TextEditorComparer, UriComparer } from '../comparers';
import { BuiltInCommands, GlyphChars } from '../constants'; import { BuiltInCommands, GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorTracker } from '../trackers/activeEditorTracker'; import { ActiveEditorTracker } from '../trackers/activeEditorTracker';
import { ActiveEditorCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; import { ActiveEditorCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
@ -86,7 +87,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'CloseUnchangedFilesCommand'); Logger.error(ex, 'CloseUnchangedFilesCommand');
return window.showErrorMessage(`Unable to close unchanged files. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to close unchanged files');
} }
} }
} }

+ 3
- 2
src/commands/copyMessageToClipboard.ts View File

@ -4,6 +4,7 @@ import { TextEditor, Uri, window } from 'vscode';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri } from '../git/gitService'; import { GitUri } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system'; import { Iterables } from '../system';
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common'; import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common';
@ -70,7 +71,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'CopyMessageToClipboardCommand', `getBlameForLine(${blameline})`); Logger.error(ex, 'CopyMessageToClipboardCommand', `getBlameForLine(${blameline})`);
return window.showErrorMessage(`Unable to copy message. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to copy message');
} }
} }
@ -93,7 +94,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
} }
Logger.error(ex, 'CopyMessageToClipboardCommand'); Logger.error(ex, 'CopyMessageToClipboardCommand');
return window.showErrorMessage(`Unable to copy message. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to copy message');
} }
} }
} }

+ 3
- 2
src/commands/copyShaToClipboard.ts View File

@ -4,6 +4,7 @@ import { TextEditor, Uri, window } from 'vscode';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri } from '../git/gitService'; import { GitUri } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { Iterables } from '../system'; import { Iterables } from '../system';
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common'; import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common';
@ -58,7 +59,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'CopyShaToClipboardCommand', `getBlameForLine(${blameline})`); Logger.error(ex, 'CopyShaToClipboardCommand', `getBlameForLine(${blameline})`);
return window.showErrorMessage(`Unable to copy commit id. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to copy ommit id');
} }
} }
@ -74,7 +75,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
} }
Logger.error(ex, 'CopyShaToClipboardCommand'); Logger.error(ex, 'CopyShaToClipboardCommand');
return window.showErrorMessage(`Unable to copy commit id. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to copy ommit id');
} }
} }
} }

+ 3
- 2
src/commands/diffBranchWithBranch.ts View File

@ -1,8 +1,9 @@
'use strict'; 'use strict';
import { CancellationTokenSource, TextEditor, Uri, window } from 'vscode';
import { CancellationTokenSource, TextEditor, Uri } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks'; import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
@ -85,7 +86,7 @@ export class DiffBranchWithBranchCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'DiffBranchWithBranchCommand'); Logger.error(ex, 'DiffBranchWithBranchCommand');
return window.showErrorMessage(`Unable to open branch compare. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open branch compare');
} }
finally { finally {
progressCancellation && progressCancellation.cancel(); progressCancellation && progressCancellation.cancel();

+ 2
- 1
src/commands/diffDirectory.ts View File

@ -3,6 +3,7 @@ import { CancellationTokenSource, commands, TextEditor, Uri, window } from 'vsco
import { BuiltInCommands, GlyphChars } from '../constants'; import { BuiltInCommands, GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks'; import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks';
import { ComparisonResultsNode } from '../views/nodes'; import { ComparisonResultsNode } from '../views/nodes';
import { import {
@ -111,7 +112,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
} }
Logger.error(ex, 'DiffDirectoryCommand'); Logger.error(ex, 'DiffDirectoryCommand');
return window.showErrorMessage(`Unable to open directory compare. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open directory compare');
} }
finally { finally {
progressCancellation && progressCancellation.cancel(); progressCancellation && progressCancellation.cancel();

+ 1
- 1
src/commands/diffLineWithPrevious.ts View File

@ -57,7 +57,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'DiffLineWithPreviousCommand', `getBlameForLine(${blameline})`); Logger.error(ex, 'DiffLineWithPreviousCommand', `getBlameForLine(${blameline})`);
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open compare');
} }
} }

+ 1
- 1
src/commands/diffLineWithWorking.ts View File

@ -63,7 +63,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'DiffLineWithWorkingCommand', `getBlameForLine(${blameline})`); Logger.error(ex, 'DiffLineWithWorkingCommand', `getBlameForLine(${blameline})`);
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open compare');
} }
} }

+ 3
- 2
src/commands/diffWith.ts View File

@ -1,10 +1,11 @@
'use strict'; 'use strict';
import * as path from 'path'; import * as path from 'path';
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window } from 'vscode';
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, ViewColumn } from 'vscode';
import { BuiltInCommands, GlyphChars } from '../constants'; import { BuiltInCommands, GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitCommit, GitService, GitUri } from '../git/gitService'; import { GitCommit, GitService, GitUri } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, Commands } from './common'; import { ActiveEditorCommand, Commands } from './common';
export interface DiffWithCommandArgsRevision { export interface DiffWithCommandArgsRevision {
@ -174,7 +175,7 @@ export class DiffWithCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'DiffWithCommand', 'getVersionedFile'); Logger.error(ex, 'DiffWithCommand', 'getVersionedFile');
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open compare');
} }
} }
} }

+ 1
- 1
src/commands/diffWithNext.ts View File

@ -84,7 +84,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'DiffWithNextCommand', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`); Logger.error(ex, 'DiffWithNextCommand', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`);
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open compare');
} }
} }

+ 1
- 1
src/commands/diffWithPrevious.ts View File

@ -145,7 +145,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'DiffWithPreviousCommand', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`); Logger.error(ex, 'DiffWithPreviousCommand', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`);
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open compare');
} }
} }

+ 1
- 1
src/commands/diffWithRevision.ts View File

@ -156,7 +156,7 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'DiffWithRevisionCommand'); Logger.error(ex, 'DiffWithRevisionCommand');
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open compare');
} }
finally { finally {
progressCancellation.cancel(); progressCancellation.cancel();

+ 1
- 1
src/commands/diffWithWorking.ts View File

@ -73,7 +73,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
'DiffWithWorkingCommand', 'DiffWithWorkingCommand',
`getLogCommit(${gitUri.repoPath}, ${gitUri.fsPath}, ${gitUri.sha})` `getLogCommit(${gitUri.repoPath}, ${gitUri.fsPath}, ${gitUri.sha})`
); );
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open compare');
} }
} }

+ 2
- 1
src/commands/externalDiff.ts View File

@ -3,6 +3,7 @@ import { commands, SourceControlResourceState, Uri, window } from 'vscode';
import { BuiltInCommands, GlyphChars } from '../constants'; import { BuiltInCommands, GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { Arrays } from '../system'; import { Arrays } from '../system';
import { Command, CommandContext, Commands, getRepoPathOrActiveOrPrompt } from './common'; import { Command, CommandContext, Commands, getRepoPathOrActiveOrPrompt } from './common';
@ -135,7 +136,7 @@ export class ExternalDiffCommand extends Command {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ExternalDiffCommand'); Logger.error(ex, 'ExternalDiffCommand');
return window.showErrorMessage(`Unable to open changes in diff tool. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open changes in diff tool');
} }
} }
} }

+ 2
- 1
src/commands/openChangedFiles.ts View File

@ -3,6 +3,7 @@ import { TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { Arrays } from '../system'; import { Arrays } from '../system';
import { ActiveEditorCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt, openEditor } from './common'; import { ActiveEditorCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt, openEditor } from './common';
@ -43,7 +44,7 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'OpenChangedFilesCommand'); Logger.error(ex, 'OpenChangedFilesCommand');
return window.showErrorMessage(`Unable to open changed files. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open changed files');
} }
} }
} }

+ 1
- 1
src/commands/openFileRevision.ts View File

@ -182,7 +182,7 @@ export class OpenFileRevisionCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'OpenFileRevisionCommand'); Logger.error(ex, 'OpenFileRevisionCommand');
return window.showErrorMessage(`Unable to open file revision. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open file revision');
} }
finally { finally {
progressCancellation && progressCancellation.cancel(); progressCancellation && progressCancellation.cancel();

+ 3
- 2
src/commands/openInRemote.ts View File

@ -1,8 +1,9 @@
'use strict'; 'use strict';
import { TextEditor, Uri, window } from 'vscode';
import { TextEditor, Uri } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { GitLogCommit, GitRemote, GitService, RemoteResource, RemoteResourceType } from '../git/gitService'; import { GitLogCommit, GitRemote, GitService, RemoteResource, RemoteResourceType } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickpicks'; import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickpicks';
import { Strings } from '../system'; import { Strings } from '../system';
import { ActiveEditorCommand, Commands } from './common'; import { ActiveEditorCommand, Commands } from './common';
@ -96,7 +97,7 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'OpenInRemoteCommand'); Logger.error(ex, 'OpenInRemoteCommand');
return window.showErrorMessage(`Unable to open in remote provider. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open in remote provider');
} }
} }

+ 3
- 2
src/commands/openWorkingFile.ts View File

@ -1,10 +1,11 @@
'use strict'; 'use strict';
import * as path from 'path'; import * as path from 'path';
import { Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
import { Range, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
import { FileAnnotationType } from '../configuration'; import { FileAnnotationType } from '../configuration';
import { Container } from '../container'; import { Container } from '../container';
import { GitUri } from '../git/gitService'; import { GitUri } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, Commands, getCommandUri, openEditor } from './common'; import { ActiveEditorCommand, Commands, getCommandUri, openEditor } from './common';
export interface OpenWorkingFileCommandArgs { export interface OpenWorkingFileCommandArgs {
@ -56,7 +57,7 @@ export class OpenWorkingFileCommand extends ActiveEditorCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'OpenWorkingFileCommand'); Logger.error(ex, 'OpenWorkingFileCommand');
return window.showErrorMessage(`Unable to open working file. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to open working file');
} }
} }
} }

+ 2
- 1
src/commands/showCommitSearch.ts View File

@ -4,6 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitRepoSearchBy, GitService, GitUri } from '../git/gitService'; import { GitRepoSearchBy, GitService, GitUri } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, CommitsQuickPick, ShowCommitsSearchInResultsQuickPickItem } from '../quickpicks'; import { CommandQuickPickItem, CommitsQuickPick, ShowCommitsSearchInResultsQuickPickItem } from '../quickpicks';
import { Strings } from '../system'; import { Strings } from '../system';
import { Iterables } from '../system/iterable'; import { Iterables } from '../system/iterable';
@ -183,7 +184,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ShowCommitSearchCommand'); Logger.error(ex, 'ShowCommitSearchCommand');
return window.showErrorMessage(`Unable to find commits. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to find commits');
} }
finally { finally {
progressCancellation.cancel(); progressCancellation.cancel();

+ 3
- 2
src/commands/showLastQuickPick.ts View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
import { commands, window } from 'vscode';
import { commands } from 'vscode';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { Command, Commands, getLastCommand } from './common'; import { Command, Commands, getLastCommand } from './common';
export class ShowLastQuickPickCommand extends Command { export class ShowLastQuickPickCommand extends Command {
@ -17,7 +18,7 @@ export class ShowLastQuickPickCommand extends Command {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ShowLastQuickPickCommand'); Logger.error(ex, 'ShowLastQuickPickCommand');
return window.showErrorMessage(`Unable to show last quick pick. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to show last quick pick');
} }
} }
} }

+ 2
- 1
src/commands/showQuickBranchHistory.ts View File

@ -4,6 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitLog, GitUri } from '../git/gitService'; import { GitLog, GitUri } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickpicks'; import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickpicks';
import { Strings } from '../system'; import { Strings } from '../system';
import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
@ -116,7 +117,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ShowQuickBranchHistoryCommand'); Logger.error(ex, 'ShowQuickBranchHistoryCommand');
return window.showErrorMessage(`Unable to show branch history. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to show branch history');
} }
finally { finally {
progressCancellation && progressCancellation.cancel(); progressCancellation && progressCancellation.cancel();

+ 2
- 2
src/commands/showQuickCommitDetails.ts View File

@ -87,7 +87,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ShowQuickCommitDetailsCommand', `getBlameForLine(${blameline})`); Logger.error(ex, 'ShowQuickCommitDetailsCommand', `getBlameForLine(${blameline})`);
return window.showErrorMessage(`Unable to show commit details. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to show commit details');
} }
} }
@ -165,7 +165,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ShowQuickCommitDetailsCommand'); Logger.error(ex, 'ShowQuickCommitDetailsCommand');
return window.showErrorMessage(`Unable to show commit details. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to show commit details');
} }
} }
} }

+ 1
- 1
src/commands/showQuickCommitFileDetails.ts View File

@ -179,7 +179,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ShowQuickCommitFileDetailsCommand'); Logger.error(ex, 'ShowQuickCommitFileDetailsCommand');
return window.showErrorMessage(`Unable to show commit file details. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to show commit file details');
} }
} }
} }

+ 3
- 2
src/commands/showQuickCurrentBranchHistory.ts View File

@ -1,8 +1,9 @@
'use strict'; 'use strict';
import { commands, TextEditor, Uri, window } from 'vscode';
import { commands, TextEditor, Uri } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem } from '../quickpicks'; import { CommandQuickPickItem } from '../quickpicks';
import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { ShowQuickBranchHistoryCommandArgs } from './showQuickBranchHistory'; import { ShowQuickBranchHistoryCommandArgs } from './showQuickBranchHistory';
@ -38,7 +39,7 @@ export class ShowQuickCurrentBranchHistoryCommand extends ActiveEditorCachedComm
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ShowQuickCurrentBranchHistoryCommand'); Logger.error(ex, 'ShowQuickCurrentBranchHistoryCommand');
return window.showErrorMessage(`Unable to show branch history. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to show branch history');
} }
} }
} }

+ 1
- 1
src/commands/showQuickFileHistory.ts View File

@ -163,7 +163,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ShowQuickFileHistoryCommand'); Logger.error(ex, 'ShowQuickFileHistoryCommand');
return window.showErrorMessage(`Unable to show file history. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to show file history');
} }
finally { finally {
progressCancellation.cancel(); progressCancellation.cancel();

+ 2
- 1
src/commands/showQuickRepoStatus.ts View File

@ -3,6 +3,7 @@ import { TextEditor, Uri, window } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickpicks'; import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickpicks';
import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
@ -38,7 +39,7 @@ export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ShowQuickRepoStatusCommand'); Logger.error(ex, 'ShowQuickRepoStatusCommand');
return window.showErrorMessage(`Unable to show repository status. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to show repository status');
} }
} }
} }

+ 2
- 1
src/commands/showQuickStashList.ts View File

@ -3,6 +3,7 @@ import { commands, TextEditor, Uri, window } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, StashListQuickPick } from '../quickpicks'; import { CommandQuickPickItem, StashListQuickPick } from '../quickpicks';
import { Strings } from '../system'; import { Strings } from '../system';
import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
@ -69,7 +70,7 @@ export class ShowQuickStashListCommand extends ActiveEditorCachedCommand {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'ShowQuickStashListCommand'); Logger.error(ex, 'ShowQuickStashListCommand');
return window.showErrorMessage(`Unable to show stashed changes. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to show stashed changes');
} }
finally { finally {
progressCancellation.cancel(); progressCancellation.cancel();

+ 2
- 1
src/commands/stashApply.ts View File

@ -4,6 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitStashCommit } from '../git/gitService'; import { GitStashCommit } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, RepositoriesQuickPick, StashListQuickPick } from '../quickpicks'; import { CommandQuickPickItem, RepositoriesQuickPick, StashListQuickPick } from '../quickpicks';
import { Strings } from '../system'; import { Strings } from '../system';
import { Command, CommandContext, Commands, isCommandViewContextWithCommit } from './common'; import { Command, CommandContext, Commands, isCommandViewContextWithCommit } from './common';
@ -132,7 +133,7 @@ export class StashApplyCommand extends Command {
return window.showInformationMessage(`Stash applied with conflicts`); return window.showInformationMessage(`Stash applied with conflicts`);
} }
else { else {
return window.showErrorMessage(`Unable to apply stash. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to apply stash');
} }
} }
} }

+ 2
- 1
src/commands/stashDelete.ts View File

@ -4,6 +4,7 @@ import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { GitStashCommit } from '../git/gitService'; import { GitStashCommit } from '../git/gitService';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem } from '../quickpicks'; import { CommandQuickPickItem } from '../quickpicks';
import { Command, CommandContext, Commands, isCommandViewContextWithCommit } from './common'; import { Command, CommandContext, Commands, isCommandViewContextWithCommit } from './common';
@ -63,7 +64,7 @@ export class StashDeleteCommand extends Command {
} }
catch (ex) { catch (ex) {
Logger.error(ex, 'StashDeleteCommand'); Logger.error(ex, 'StashDeleteCommand');
return window.showErrorMessage(`Unable to delete stash. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to delete stash');
} }
} }
} }

+ 2
- 1
src/commands/stashSave.ts View File

@ -3,6 +3,7 @@ import { InputBoxOptions, Uri, window } from 'vscode';
import { GlyphChars } from '../constants'; import { GlyphChars } from '../constants';
import { Container } from '../container'; import { Container } from '../container';
import { Logger } from '../logger'; import { Logger } from '../logger';
import { Messages } from '../messages';
import { CommandQuickPickItem, RepositoriesQuickPick } from '../quickpicks'; import { CommandQuickPickItem, RepositoriesQuickPick } from '../quickpicks';
import { Command, CommandContext, Commands } from './common'; import { Command, CommandContext, Commands } from './common';
@ -71,7 +72,7 @@ export class StashSaveCommand extends Command {
if (msg.includes('newer version of Git')) { if (msg.includes('newer version of Git')) {
return window.showErrorMessage(`Unable to save stash. ${msg}`); return window.showErrorMessage(`Unable to save stash. ${msg}`);
} }
return window.showErrorMessage(`Unable to save stash. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to save stash');
} }
} }
} }

+ 2
- 1
src/git/remotes/provider.ts View File

@ -3,6 +3,7 @@ import * as clipboard from 'clipboardy';
import { commands, Range, Uri, window } from 'vscode'; import { commands, Range, Uri, window } from 'vscode';
import { BuiltInCommands } from '../../constants'; import { BuiltInCommands } from '../../constants';
import { Logger } from '../../logger'; import { Logger } from '../../logger';
import { Messages } from '../../messages';
import { GitLogCommit } from '../models/logCommit'; import { GitLogCommit } from '../models/logCommit';
export enum RemoteResourceType { export enum RemoteResourceType {
@ -132,7 +133,7 @@ export abstract class RemoteProvider {
} }
Logger.error(ex, 'CopyRemoteUrlToClipboardCommand'); Logger.error(ex, 'CopyRemoteUrlToClipboardCommand');
return window.showErrorMessage(`Unable to copy remote url. See output channel for more details`);
return Messages.showGenericErrorMessage('Unable to copy remote url');
} }
} }

+ 6
- 0
src/logger.ts View File

@ -83,6 +83,12 @@ export class Logger {
} }
} }
static showOutputChannel() {
if (this.output !== undefined) {
this.output.show();
}
}
private static get timestamp(): string { private static get timestamp(): string {
const now = new Date(); const now = new Date();
const time = now const time = now

+ 24
- 5
src/messages.ts View File

@ -40,6 +40,22 @@ export class Messages {
); );
} }
static async showGenericErrorMessage(message: string): Promise<MessageItem | undefined> {
const actions: MessageItem[] = [{ title: 'Open Output Channel' }];
const result = await Messages.showMessage(
'error',
`${message}. See output channel for more details`,
undefined,
null,
...actions
);
if (result !== undefined) {
Logger.showOutputChannel();
}
return result;
}
static showFileNotUnderSourceControlWarningMessage(message: string): Promise<MessageItem | undefined> { static showFileNotUnderSourceControlWarningMessage(message: string): Promise<MessageItem | undefined> {
return Messages.showMessage( return Messages.showMessage(
'warn', 'warn',
@ -121,18 +137,21 @@ export class Messages {
private static async showMessage<T extends MessageItem>( private static async showMessage<T extends MessageItem>(
type: 'info' | 'warn' | 'error', type: 'info' | 'warn' | 'error',
message: string, message: string,
suppressionKey: SuppressedMessages,
suppressionKey?: SuppressedMessages,
dontShowAgain: T | null = { title: "Don't Show Again" } as T, dontShowAgain: T | null = { title: "Don't Show Again" } as T,
...actions: T[] ...actions: T[]
): Promise<T | undefined> { ): Promise<T | undefined> {
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain})`); Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain})`);
if (configuration.get<boolean>(configuration.name('advanced')('messages')(suppressionKey).value)) {
if (
suppressionKey !== undefined &&
configuration.get<boolean>(configuration.name('advanced')('messages')(suppressionKey).value)
) {
Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) skipped`); Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) skipped`);
return undefined; return undefined;
} }
if (dontShowAgain !== null) {
if (suppressionKey !== undefined && dontShowAgain !== null) {
actions.push(dontShowAgain); actions.push(dontShowAgain);
} }
@ -151,11 +170,11 @@ export class Messages {
break; break;
} }
if (dontShowAgain === null || result === dontShowAgain) {
if ((suppressionKey !== undefined && dontShowAgain === null) || result === dontShowAgain) {
Logger.log( Logger.log(
`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) don't show again requested` `ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) don't show again requested`
); );
await this.suppressedMessage(suppressionKey);
await this.suppressedMessage(suppressionKey!);
if (result === dontShowAgain) return undefined; if (result === dontShowAgain) return undefined;
} }

Loading…
Cancel
Save