diff --git a/src/commands/clearFileAnnotations.ts b/src/commands/clearFileAnnotations.ts index 3d6f3e2..3d4b266 100644 --- a/src/commands/clearFileAnnotations.ts +++ b/src/commands/clearFileAnnotations.ts @@ -3,6 +3,7 @@ import { TextEditor, TextEditorEdit, Uri, window } from 'vscode'; import { UriComparer } from '../comparers'; import { Container } from '../container'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { Commands, EditorCommand } from './common'; export class ClearFileAnnotationsCommand extends EditorCommand { @@ -26,7 +27,7 @@ export class ClearFileAnnotationsCommand extends EditorCommand { } catch (ex) { 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'); } } } diff --git a/src/commands/closeUnchangedFiles.ts b/src/commands/closeUnchangedFiles.ts index 7e6d9c4..ba03f2d 100644 --- a/src/commands/closeUnchangedFiles.ts +++ b/src/commands/closeUnchangedFiles.ts @@ -4,6 +4,7 @@ import { TextEditorComparer, UriComparer } from '../comparers'; import { BuiltInCommands, GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { ActiveEditorTracker } from '../trackers/activeEditorTracker'; import { ActiveEditorCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; @@ -86,7 +87,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand { } catch (ex) { 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'); } } } diff --git a/src/commands/copyMessageToClipboard.ts b/src/commands/copyMessageToClipboard.ts index f677149..99ef350 100644 --- a/src/commands/copyMessageToClipboard.ts +++ b/src/commands/copyMessageToClipboard.ts @@ -4,6 +4,7 @@ import { TextEditor, Uri, window } from 'vscode'; import { Container } from '../container'; import { GitUri } from '../git/gitService'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { Iterables } from '../system'; import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common'; @@ -70,7 +71,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand { } catch (ex) { 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'); - return window.showErrorMessage(`Unable to copy message. See output channel for more details`); + return Messages.showGenericErrorMessage('Unable to copy message'); } } } diff --git a/src/commands/copyShaToClipboard.ts b/src/commands/copyShaToClipboard.ts index 065efbb..ece7df7 100644 --- a/src/commands/copyShaToClipboard.ts +++ b/src/commands/copyShaToClipboard.ts @@ -4,6 +4,7 @@ import { TextEditor, Uri, window } from 'vscode'; import { Container } from '../container'; import { GitUri } from '../git/gitService'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { Iterables } from '../system'; import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, isCommandViewContextWithCommit } from './common'; @@ -58,7 +59,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand { } catch (ex) { 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'); - return window.showErrorMessage(`Unable to copy commit id. See output channel for more details`); + return Messages.showGenericErrorMessage('Unable to copy ommit id'); } } } diff --git a/src/commands/diffBranchWithBranch.ts b/src/commands/diffBranchWithBranch.ts index 9bf4e63..0edcfe2 100644 --- a/src/commands/diffBranchWithBranch.ts +++ b/src/commands/diffBranchWithBranch.ts @@ -1,8 +1,9 @@ 'use strict'; -import { CancellationTokenSource, TextEditor, Uri, window } from 'vscode'; +import { CancellationTokenSource, TextEditor, Uri } from 'vscode'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks'; import { ActiveEditorCommand, CommandContext, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; @@ -85,7 +86,7 @@ export class DiffBranchWithBranchCommand extends ActiveEditorCommand { } catch (ex) { 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 { progressCancellation && progressCancellation.cancel(); diff --git a/src/commands/diffDirectory.ts b/src/commands/diffDirectory.ts index 0b63857..3e6c8b0 100644 --- a/src/commands/diffDirectory.ts +++ b/src/commands/diffDirectory.ts @@ -3,6 +3,7 @@ import { CancellationTokenSource, commands, TextEditor, Uri, window } from 'vsco import { BuiltInCommands, GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { BranchesAndTagsQuickPick, CommandQuickPickItem } from '../quickpicks'; import { ComparisonResultsNode } from '../views/nodes'; import { @@ -111,7 +112,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand { } 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 { progressCancellation && progressCancellation.cancel(); diff --git a/src/commands/diffLineWithPrevious.ts b/src/commands/diffLineWithPrevious.ts index c3ce062..caedb9f 100644 --- a/src/commands/diffLineWithPrevious.ts +++ b/src/commands/diffLineWithPrevious.ts @@ -57,7 +57,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand { } catch (ex) { 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'); } } diff --git a/src/commands/diffLineWithWorking.ts b/src/commands/diffLineWithWorking.ts index c835d06..8f49c74 100644 --- a/src/commands/diffLineWithWorking.ts +++ b/src/commands/diffLineWithWorking.ts @@ -63,7 +63,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand { } catch (ex) { 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'); } } diff --git a/src/commands/diffWith.ts b/src/commands/diffWith.ts index 2a565d7..71e3628 100644 --- a/src/commands/diffWith.ts +++ b/src/commands/diffWith.ts @@ -1,10 +1,11 @@ 'use strict'; 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 { Container } from '../container'; import { GitCommit, GitService, GitUri } from '../git/gitService'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { ActiveEditorCommand, Commands } from './common'; export interface DiffWithCommandArgsRevision { @@ -174,7 +175,7 @@ export class DiffWithCommand extends ActiveEditorCommand { } catch (ex) { 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'); } } } diff --git a/src/commands/diffWithNext.ts b/src/commands/diffWithNext.ts index 8f6040d..799514d 100644 --- a/src/commands/diffWithNext.ts +++ b/src/commands/diffWithNext.ts @@ -84,7 +84,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand { } catch (ex) { 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'); } } diff --git a/src/commands/diffWithPrevious.ts b/src/commands/diffWithPrevious.ts index 70d821f..1f45924 100644 --- a/src/commands/diffWithPrevious.ts +++ b/src/commands/diffWithPrevious.ts @@ -145,7 +145,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand { } catch (ex) { 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'); } } diff --git a/src/commands/diffWithRevision.ts b/src/commands/diffWithRevision.ts index 6dc8b15..ddc7c23 100644 --- a/src/commands/diffWithRevision.ts +++ b/src/commands/diffWithRevision.ts @@ -156,7 +156,7 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand { } catch (ex) { 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 { progressCancellation.cancel(); diff --git a/src/commands/diffWithWorking.ts b/src/commands/diffWithWorking.ts index 808752a..d70f8f3 100644 --- a/src/commands/diffWithWorking.ts +++ b/src/commands/diffWithWorking.ts @@ -73,7 +73,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand { 'DiffWithWorkingCommand', `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'); } } diff --git a/src/commands/externalDiff.ts b/src/commands/externalDiff.ts index 7db88dd..1c19666 100644 --- a/src/commands/externalDiff.ts +++ b/src/commands/externalDiff.ts @@ -3,6 +3,7 @@ import { commands, SourceControlResourceState, Uri, window } from 'vscode'; import { BuiltInCommands, GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { Arrays } from '../system'; import { Command, CommandContext, Commands, getRepoPathOrActiveOrPrompt } from './common'; @@ -135,7 +136,7 @@ export class ExternalDiffCommand extends Command { } catch (ex) { 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'); } } } diff --git a/src/commands/openChangedFiles.ts b/src/commands/openChangedFiles.ts index 534ac91..34ebf0c 100644 --- a/src/commands/openChangedFiles.ts +++ b/src/commands/openChangedFiles.ts @@ -3,6 +3,7 @@ import { TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { Arrays } from '../system'; import { ActiveEditorCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt, openEditor } from './common'; @@ -43,7 +44,7 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand { } catch (ex) { 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'); } } } diff --git a/src/commands/openFileRevision.ts b/src/commands/openFileRevision.ts index 11c7fcc..9723317 100644 --- a/src/commands/openFileRevision.ts +++ b/src/commands/openFileRevision.ts @@ -182,7 +182,7 @@ export class OpenFileRevisionCommand extends ActiveEditorCommand { } catch (ex) { 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 { progressCancellation && progressCancellation.cancel(); diff --git a/src/commands/openInRemote.ts b/src/commands/openInRemote.ts index 2c17c55..bdf8d12 100644 --- a/src/commands/openInRemote.ts +++ b/src/commands/openInRemote.ts @@ -1,8 +1,9 @@ 'use strict'; -import { TextEditor, Uri, window } from 'vscode'; +import { TextEditor, Uri } from 'vscode'; import { GlyphChars } from '../constants'; import { GitLogCommit, GitRemote, GitService, RemoteResource, RemoteResourceType } from '../git/gitService'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickpicks'; import { Strings } from '../system'; import { ActiveEditorCommand, Commands } from './common'; @@ -96,7 +97,7 @@ export class OpenInRemoteCommand extends ActiveEditorCommand { } catch (ex) { 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'); } } diff --git a/src/commands/openWorkingFile.ts b/src/commands/openWorkingFile.ts index daf1441..f9a654d 100644 --- a/src/commands/openWorkingFile.ts +++ b/src/commands/openWorkingFile.ts @@ -1,10 +1,11 @@ 'use strict'; 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 { Container } from '../container'; import { GitUri } from '../git/gitService'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { ActiveEditorCommand, Commands, getCommandUri, openEditor } from './common'; export interface OpenWorkingFileCommandArgs { @@ -56,7 +57,7 @@ export class OpenWorkingFileCommand extends ActiveEditorCommand { } catch (ex) { 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'); } } } diff --git a/src/commands/showCommitSearch.ts b/src/commands/showCommitSearch.ts index 762a712..49c9338 100644 --- a/src/commands/showCommitSearch.ts +++ b/src/commands/showCommitSearch.ts @@ -4,6 +4,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitRepoSearchBy, GitService, GitUri } from '../git/gitService'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { CommandQuickPickItem, CommitsQuickPick, ShowCommitsSearchInResultsQuickPickItem } from '../quickpicks'; import { Strings } from '../system'; import { Iterables } from '../system/iterable'; @@ -183,7 +184,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand { } catch (ex) { 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 { progressCancellation.cancel(); diff --git a/src/commands/showLastQuickPick.ts b/src/commands/showLastQuickPick.ts index 77c1b61..43cb15d 100644 --- a/src/commands/showLastQuickPick.ts +++ b/src/commands/showLastQuickPick.ts @@ -1,6 +1,7 @@ 'use strict'; -import { commands, window } from 'vscode'; +import { commands } from 'vscode'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { Command, Commands, getLastCommand } from './common'; export class ShowLastQuickPickCommand extends Command { @@ -17,7 +18,7 @@ export class ShowLastQuickPickCommand extends Command { } catch (ex) { 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'); } } } diff --git a/src/commands/showQuickBranchHistory.ts b/src/commands/showQuickBranchHistory.ts index 7ac81ce..fc02d89 100644 --- a/src/commands/showQuickBranchHistory.ts +++ b/src/commands/showQuickBranchHistory.ts @@ -4,6 +4,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitLog, GitUri } from '../git/gitService'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickpicks'; import { Strings } from '../system'; import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; @@ -116,7 +117,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand { } catch (ex) { 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 { progressCancellation && progressCancellation.cancel(); diff --git a/src/commands/showQuickCommitDetails.ts b/src/commands/showQuickCommitDetails.ts index 709b1a6..3be4e3c 100644 --- a/src/commands/showQuickCommitDetails.ts +++ b/src/commands/showQuickCommitDetails.ts @@ -87,7 +87,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand { } catch (ex) { 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) { 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'); } } } diff --git a/src/commands/showQuickCommitFileDetails.ts b/src/commands/showQuickCommitFileDetails.ts index d900918..43498bb 100644 --- a/src/commands/showQuickCommitFileDetails.ts +++ b/src/commands/showQuickCommitFileDetails.ts @@ -179,7 +179,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand } catch (ex) { 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'); } } } diff --git a/src/commands/showQuickCurrentBranchHistory.ts b/src/commands/showQuickCurrentBranchHistory.ts index 16babfa..610f6dd 100644 --- a/src/commands/showQuickCurrentBranchHistory.ts +++ b/src/commands/showQuickCurrentBranchHistory.ts @@ -1,8 +1,9 @@ 'use strict'; -import { commands, TextEditor, Uri, window } from 'vscode'; +import { commands, TextEditor, Uri } from 'vscode'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { CommandQuickPickItem } from '../quickpicks'; import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; import { ShowQuickBranchHistoryCommandArgs } from './showQuickBranchHistory'; @@ -38,7 +39,7 @@ export class ShowQuickCurrentBranchHistoryCommand extends ActiveEditorCachedComm } catch (ex) { 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'); } } } diff --git a/src/commands/showQuickFileHistory.ts b/src/commands/showQuickFileHistory.ts index 741e8b2..190aa8d 100644 --- a/src/commands/showQuickFileHistory.ts +++ b/src/commands/showQuickFileHistory.ts @@ -163,7 +163,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand { } catch (ex) { 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 { progressCancellation.cancel(); diff --git a/src/commands/showQuickRepoStatus.ts b/src/commands/showQuickRepoStatus.ts index dba8d47..26cda6f 100644 --- a/src/commands/showQuickRepoStatus.ts +++ b/src/commands/showQuickRepoStatus.ts @@ -3,6 +3,7 @@ import { TextEditor, Uri, window } from 'vscode'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickpicks'; import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; @@ -38,7 +39,7 @@ export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand { } catch (ex) { 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'); } } } diff --git a/src/commands/showQuickStashList.ts b/src/commands/showQuickStashList.ts index 376a8cb..c6c3f25 100644 --- a/src/commands/showQuickStashList.ts +++ b/src/commands/showQuickStashList.ts @@ -3,6 +3,7 @@ import { commands, TextEditor, Uri, window } from 'vscode'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { CommandQuickPickItem, StashListQuickPick } from '../quickpicks'; import { Strings } from '../system'; import { ActiveEditorCachedCommand, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common'; @@ -69,7 +70,7 @@ export class ShowQuickStashListCommand extends ActiveEditorCachedCommand { } catch (ex) { 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 { progressCancellation.cancel(); diff --git a/src/commands/stashApply.ts b/src/commands/stashApply.ts index 899ba72..bda0f77 100644 --- a/src/commands/stashApply.ts +++ b/src/commands/stashApply.ts @@ -4,6 +4,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitStashCommit } from '../git/gitService'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { CommandQuickPickItem, RepositoriesQuickPick, StashListQuickPick } from '../quickpicks'; import { Strings } from '../system'; import { Command, CommandContext, Commands, isCommandViewContextWithCommit } from './common'; @@ -132,7 +133,7 @@ export class StashApplyCommand extends Command { return window.showInformationMessage(`Stash applied with conflicts`); } else { - return window.showErrorMessage(`Unable to apply stash. See output channel for more details`); + return Messages.showGenericErrorMessage('Unable to apply stash'); } } } diff --git a/src/commands/stashDelete.ts b/src/commands/stashDelete.ts index 837fd58..f4858c8 100644 --- a/src/commands/stashDelete.ts +++ b/src/commands/stashDelete.ts @@ -4,6 +4,7 @@ import { GlyphChars } from '../constants'; import { Container } from '../container'; import { GitStashCommit } from '../git/gitService'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { CommandQuickPickItem } from '../quickpicks'; import { Command, CommandContext, Commands, isCommandViewContextWithCommit } from './common'; @@ -63,7 +64,7 @@ export class StashDeleteCommand extends Command { } catch (ex) { Logger.error(ex, 'StashDeleteCommand'); - return window.showErrorMessage(`Unable to delete stash. See output channel for more details`); + return Messages.showGenericErrorMessage('Unable to delete stash'); } } } diff --git a/src/commands/stashSave.ts b/src/commands/stashSave.ts index 54696fb..e0b2340 100644 --- a/src/commands/stashSave.ts +++ b/src/commands/stashSave.ts @@ -3,6 +3,7 @@ import { InputBoxOptions, Uri, window } from 'vscode'; import { GlyphChars } from '../constants'; import { Container } from '../container'; import { Logger } from '../logger'; +import { Messages } from '../messages'; import { CommandQuickPickItem, RepositoriesQuickPick } from '../quickpicks'; import { Command, CommandContext, Commands } from './common'; @@ -71,7 +72,7 @@ export class StashSaveCommand extends Command { if (msg.includes('newer version of Git')) { 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'); } } } diff --git a/src/git/remotes/provider.ts b/src/git/remotes/provider.ts index af22ba6..8530f7e 100644 --- a/src/git/remotes/provider.ts +++ b/src/git/remotes/provider.ts @@ -3,6 +3,7 @@ import * as clipboard from 'clipboardy'; import { commands, Range, Uri, window } from 'vscode'; import { BuiltInCommands } from '../../constants'; import { Logger } from '../../logger'; +import { Messages } from '../../messages'; import { GitLogCommit } from '../models/logCommit'; export enum RemoteResourceType { @@ -132,7 +133,7 @@ export abstract class RemoteProvider { } 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'); } } diff --git a/src/logger.ts b/src/logger.ts index 236b2cf..3b2c548 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -83,6 +83,12 @@ export class Logger { } } + static showOutputChannel() { + if (this.output !== undefined) { + this.output.show(); + } + } + private static get timestamp(): string { const now = new Date(); const time = now diff --git a/src/messages.ts b/src/messages.ts index efc8a1c..9a072f9 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -40,6 +40,22 @@ export class Messages { ); } + static async showGenericErrorMessage(message: string): Promise { + 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 { return Messages.showMessage( 'warn', @@ -121,18 +137,21 @@ export class Messages { private static async showMessage( type: 'info' | 'warn' | 'error', message: string, - suppressionKey: SuppressedMessages, + suppressionKey?: SuppressedMessages, dontShowAgain: T | null = { title: "Don't Show Again" } as T, ...actions: T[] ): Promise { Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain})`); - if (configuration.get(configuration.name('advanced')('messages')(suppressionKey).value)) { + if ( + suppressionKey !== undefined && + configuration.get(configuration.name('advanced')('messages')(suppressionKey).value) + ) { Logger.log(`ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) skipped`); return undefined; } - if (dontShowAgain !== null) { + if (suppressionKey !== undefined && dontShowAgain !== null) { actions.push(dontShowAgain); } @@ -151,11 +170,11 @@ export class Messages { break; } - if (dontShowAgain === null || result === dontShowAgain) { + if ((suppressionKey !== undefined && dontShowAgain === null) || result === dontShowAgain) { Logger.log( `ShowMessage(${type}, '${message}', ${suppressionKey}, ${dontShowAgain}) don't show again requested` ); - await this.suppressedMessage(suppressionKey); + await this.suppressedMessage(suppressionKey!); if (result === dontShowAgain) return undefined; }