mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-15 01:25:42 -05:00
Refactors Logger.error to take the Error object
This commit is contained in:
@@ -63,7 +63,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
|
||||
return undefined;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.CloseUnchangedFilesCommand]', ex);
|
||||
Logger.error(ex, 'CloseUnchangedFilesCommand');
|
||||
return window.showErrorMessage(`Unable to close unchanged files. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.CopyMessageToClipboardCommand]', `getBlameForLine(${blameline})`, ex);
|
||||
Logger.error(ex, 'CopyMessageToClipboardCommand', `getBlameForLine(${blameline})`);
|
||||
return window.showErrorMessage(`Unable to copy message. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
|
||||
return undefined;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('GitLens.CopyMessageToClipboardCommand', ex);
|
||||
Logger.error(ex, 'CopyMessageToClipboardCommand');
|
||||
return window.showErrorMessage(`Unable to copy message. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
|
||||
sha = blame.commit.sha;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.CopyShaToClipboardCommand]', `getBlameForLine(${blameline})`, ex);
|
||||
Logger.error(ex, 'CopyShaToClipboardCommand', `getBlameForLine(${blameline})`);
|
||||
return window.showErrorMessage(`Unable to copy sha. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
|
||||
return undefined;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('GitLens.CopyShaToClipboardCommand', ex);
|
||||
Logger.error(ex, 'CopyShaToClipboardCommand');
|
||||
return window.showErrorMessage(`Unable to copy sha. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
|
||||
return undefined;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('GitLens.DiffDirectoryCommand', ex);
|
||||
Logger.error(ex, 'DiffDirectoryCommand');
|
||||
return window.showErrorMessage(`Unable to open directory diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.DiffWithPreviousLineCommand]', `getBlameForLine(${blameline})`, ex);
|
||||
Logger.error(ex, 'DiffWithPreviousLineCommand', `getBlameForLine(${blameline})`);
|
||||
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
|
||||
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.DiffWithPreviousLineCommand]', 'getVersionedFile', ex);
|
||||
Logger.error(ex, 'DiffWithPreviousLineCommand', 'getVersionedFile');
|
||||
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.DiffLineWithWorkingCommand]', `getBlameForLine(${blameline})`, ex);
|
||||
Logger.error(ex, 'DiffLineWithWorkingCommand', `getBlameForLine(${blameline})`);
|
||||
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
|
||||
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.DiffWithBranchCommand]', 'getVersionedFile', ex);
|
||||
Logger.error(ex, 'DiffWithBranchCommand', 'getVersionedFile');
|
||||
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
|
||||
commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.DiffWithNextCommand]', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`, ex);
|
||||
Logger.error(ex, 'DiffWithNextCommand', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`);
|
||||
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
|
||||
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.DiffWithNextCommand]', 'getVersionedFile', ex);
|
||||
Logger.error(ex, 'DiffWithNextCommand', 'getVersionedFile');
|
||||
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
||||
commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.DiffWithPreviousCommand]', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`, ex);
|
||||
Logger.error(ex, 'DiffWithPreviousCommand', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`);
|
||||
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
||||
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.DiffWithPreviousCommand]', 'getVersionedFile', ex);
|
||||
Logger.error(ex, 'DiffWithPreviousCommand', 'getVersionedFile');
|
||||
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
|
||||
if (!commit) return window.showWarningMessage(`Unable to open diff. File is probably not under source control`);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.DiffWithWorkingCommand]', `getLogCommit(${gitUri.repoPath}, ${gitUri.fsPath}, ${gitUri.sha})`, ex);
|
||||
Logger.error(ex, 'DiffWithWorkingCommand', `getLogCommit(${gitUri.repoPath}, ${gitUri.fsPath}, ${gitUri.sha})`);
|
||||
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
|
||||
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.DiffWithWorkingCommand]', 'getVersionedFile', ex);
|
||||
Logger.error(ex, 'DiffWithWorkingCommand', 'getVersionedFile');
|
||||
return window.showErrorMessage(`Unable to open diff. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ export class Keyboard extends Disposable {
|
||||
return await command.execute();
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('Keyboard.execute', ex);
|
||||
Logger.error(ex, 'Keyboard.execute');
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand {
|
||||
return undefined;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.OpenChangedFilesCommand]', ex);
|
||||
Logger.error(ex, 'OpenChangedFilesCommand');
|
||||
return window.showErrorMessage(`Unable to open changed files. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'commit', [commit.sha]);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.OpenCommitInRemoteCommand]', ex);
|
||||
Logger.error(ex, 'OpenCommitInRemoteCommand');
|
||||
return window.showErrorMessage(`Unable to open commit in remote provider. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'file', [gitUri.getRelativePath(), branch.name, gitUri.sha]);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.OpenFileInRemoteCommand]', ex);
|
||||
Logger.error(ex, 'OpenFileInRemoteCommand');
|
||||
return window.showErrorMessage(`Unable to open file in remote provider. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
|
||||
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.OpenInRemoteCommand]', ex);
|
||||
Logger.error(ex, 'OpenInRemoteCommand');
|
||||
return window.showErrorMessage(`Unable to open in remote provider. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export class ShowBlameCommand extends EditorCommand {
|
||||
return this.annotationController.showBlameAnnotation(editor, editor.selection.active.line);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('GitLens.ShowBlameCommand', ex);
|
||||
Logger.error(ex, 'ShowBlameCommand');
|
||||
return window.showErrorMessage(`Unable to show blame annotations. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ export class ShowBlameHistoryCommand extends EditorCommand {
|
||||
return commands.executeCommand(BuiltInCommands.ShowReferences, uri, position, locations);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowBlameHistoryCommand]', 'getBlameLocations', ex);
|
||||
Logger.error(ex, 'ShowBlameHistoryCommand', 'getBlameLocations');
|
||||
return window.showErrorMessage(`Unable to show blame history. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export class ShowFileHistoryCommand extends EditorCommand {
|
||||
return commands.executeCommand(BuiltInCommands.ShowReferences, uri, position, locations);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowFileHistoryCommand]', 'getLogLocations', ex);
|
||||
Logger.error(ex, 'ShowFileHistoryCommand', 'getLogLocations');
|
||||
return window.showErrorMessage(`Unable to show file history. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export class ShowLastQuickPickCommand extends Command {
|
||||
return commands.executeCommand(command.command, ...command.args);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowLastQuickPickCommand]', ex);
|
||||
Logger.error(ex, 'ShowLastQuickPickCommand');
|
||||
return window.showErrorMessage(`Unable to show last quick pick. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
|
||||
log);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickBranchHistoryCommand]', ex);
|
||||
Logger.error(ex, 'ShowQuickBranchHistoryCommand');
|
||||
return window.showErrorMessage(`Unable to show branch history. See output channel for more details`);
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -40,7 +40,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
||||
commit = blame.commit;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickCommitDetailsCommand]', `getBlameForLine(${blameline})`, ex);
|
||||
Logger.error(ex, 'ShowQuickCommitDetailsCommand', `getBlameForLine(${blameline})`);
|
||||
return window.showErrorMessage(`Unable to show commit details. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
||||
return commands.executeCommand(Commands.ShowQuickCommitFileDetails, pick.gitUri, pick.sha, undefined, currentCommand);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickCommitDetailsCommand]', ex);
|
||||
Logger.error(ex, 'ShowQuickCommitDetailsCommand');
|
||||
return window.showErrorMessage(`Unable to show commit details. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
|
||||
workingFileName = path.relative(commit.repoPath, gitUri.fsPath);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickCommitFileDetailsCommand]', `getBlameForLine(${blameline})`, ex);
|
||||
Logger.error(ex, 'ShowQuickCommitFileDetailsCommand', `getBlameForLine(${blameline})`);
|
||||
return window.showErrorMessage(`Unable to show commit file details. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
|
||||
return undefined;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickCommitFileDetailsCommand]', ex);
|
||||
Logger.error(ex, 'ShowQuickCommitFileDetailsCommand');
|
||||
return window.showErrorMessage(`Unable to show commit file details. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export class ShowQuickCurrentBranchHistoryCommand extends ActiveEditorCachedComm
|
||||
return commands.executeCommand(Commands.ShowQuickBranchHistory, uri, branch, undefined, goBackCommand);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickCurrentBranchHistoryCommand]', ex);
|
||||
Logger.error(ex, 'ShowQuickCurrentBranchHistoryCommand');
|
||||
return window.showErrorMessage(`Unable to show branch history. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
|
||||
log);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickFileHistoryCommand]', 'data.repoPath, ', ex);
|
||||
Logger.error(ex, 'ShowQuickFileHistoryCommand');
|
||||
return window.showErrorMessage(`Unable to show file history. See output channel for more details`);
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -31,7 +31,7 @@ export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
|
||||
}
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.ShowQuickRepoStatusCommand]', ex);
|
||||
Logger.error(ex, 'ShowQuickRepoStatusCommand');
|
||||
return window.showErrorMessage(`Unable to show repository status. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ export class ToggleBlameCommand extends EditorCommand {
|
||||
return this.annotationController.toggleBlameAnnotation(editor, editor.selection.active.line);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('GitLens.ToggleBlameCommand', ex);
|
||||
Logger.error(ex, 'ToggleBlameCommand');
|
||||
return window.showErrorMessage(`Unable to show blame annotations. See output channel for more details`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export async function activate(context: ExtensionContext) {
|
||||
repoPath = await Git.getRepoPath(rootPath, gitPath);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error(ex);
|
||||
Logger.error(ex, 'Extension.activate');
|
||||
if (ex.message.includes('Unable to find git')) {
|
||||
await window.showErrorMessage(`GitLens was unable to find Git. Please make sure Git is installed. Also ensure that Git is either in the PATH, or that 'gitlens.advanced.git' is pointed to its installed location.`);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ async function gitCommand(cwd: string, ...args: any[]) {
|
||||
Logger.warn('git', ...args, ` cwd='${cwd}'`, msg && `\n ${msg.replace(/\r?\n|\r/g, ' ')}`);
|
||||
}
|
||||
else {
|
||||
Logger.error('git', ...args, ` cwd='${cwd}'`, msg && `\n ${msg.replace(/\r?\n|\r/g, ' ')}`);
|
||||
Logger.error(ex, 'git', ...args, ` cwd='${cwd}'`, msg && `\n ${msg.replace(/\r?\n|\r/g, ' ')}`);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export class RemoteProviderFactory {
|
||||
return creator(domain, path);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error(ex);
|
||||
Logger.error(ex, 'RemoteProviderFactory');
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export class GitContentProvider implements TextDocumentContentProvider {
|
||||
return text;
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error('[GitLens.GitContentProvider]', 'getVersionedFileText', ex);
|
||||
Logger.error(ex, 'GitContentProvider', 'getVersionedFileText');
|
||||
await window.showErrorMessage(`Unable to show Git revision ${data.sha.substring(0, 8)} of '${path.relative(data.repoPath, fileName)}'`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -50,13 +50,13 @@ export class Logger {
|
||||
}
|
||||
}
|
||||
|
||||
static error(message?: any, ...params: any[]): void {
|
||||
static error(ex: Error, classOrMethod?: string, ...params: any[]): void {
|
||||
if (debug) {
|
||||
console.error(ConsolePrefix, message, ...params);
|
||||
console.error(ConsolePrefix, ex, ...params);
|
||||
}
|
||||
|
||||
if (level !== OutputLevel.Silent) {
|
||||
output.appendLine([message, ...params].join(' '));
|
||||
output.appendLine([ex, ...params].join(' '));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user