Bläddra i källkod

Refactors Logger.error to take the Error object

main
Eric Amodio 7 år sedan
förälder
incheckning
e0b3dcd484
31 ändrade filer med 41 tillägg och 41 borttagningar
  1. +1
    -1
      src/commands/closeUnchangedFiles.ts
  2. +2
    -2
      src/commands/copyMessageToClipboard.ts
  3. +2
    -2
      src/commands/copyShaToClipboard.ts
  4. +1
    -1
      src/commands/diffDirectory.ts
  5. +2
    -2
      src/commands/diffLineWithPrevious.ts
  6. +1
    -1
      src/commands/diffLineWithWorking.ts
  7. +1
    -1
      src/commands/diffWithBranch.ts
  8. +2
    -2
      src/commands/diffWithNext.ts
  9. +2
    -2
      src/commands/diffWithPrevious.ts
  10. +2
    -2
      src/commands/diffWithWorking.ts
  11. +1
    -1
      src/commands/keyboard.ts
  12. +1
    -1
      src/commands/openChangedFiles.ts
  13. +1
    -1
      src/commands/openCommitInRemote.ts
  14. +1
    -1
      src/commands/openFileInRemote.ts
  15. +1
    -1
      src/commands/openInRemote.ts
  16. +1
    -1
      src/commands/showBlame.ts
  17. +1
    -1
      src/commands/showBlameHistory.ts
  18. +1
    -1
      src/commands/showFileHistory.ts
  19. +1
    -1
      src/commands/showLastQuickPick.ts
  20. +1
    -1
      src/commands/showQuickBranchHistory.ts
  21. +2
    -2
      src/commands/showQuickCommitDetails.ts
  22. +2
    -2
      src/commands/showQuickCommitFileDetails.ts
  23. +1
    -1
      src/commands/showQuickCurrentBranchHistory.ts
  24. +1
    -1
      src/commands/showQuickFileHistory.ts
  25. +1
    -1
      src/commands/showQuickRepoStatus.ts
  26. +1
    -1
      src/commands/toggleBlame.ts
  27. +1
    -1
      src/extension.ts
  28. +1
    -1
      src/git/git.ts
  29. +1
    -1
      src/git/remotes/factory.ts
  30. +1
    -1
      src/gitContentProvider.ts
  31. +3
    -3
      src/logger.ts

+ 1
- 1
src/commands/closeUnchangedFiles.ts Visa fil

@ -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`);
}
}

+ 2
- 2
src/commands/copyMessageToClipboard.ts Visa fil

@ -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`);
}
}

+ 2
- 2
src/commands/copyShaToClipboard.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/diffDirectory.ts Visa fil

@ -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`);
}
}

+ 2
- 2
src/commands/diffLineWithPrevious.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/diffLineWithWorking.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/diffWithBranch.ts Visa fil

@ -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`);
}
}

+ 2
- 2
src/commands/diffWithNext.ts Visa fil

@ -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`);
}
}

+ 2
- 2
src/commands/diffWithPrevious.ts Visa fil

@ -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`);
}
}

+ 2
- 2
src/commands/diffWithWorking.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/keyboard.ts Visa fil

@ -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;
}
}

+ 1
- 1
src/commands/openChangedFiles.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/openCommitInRemote.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/openFileInRemote.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/openInRemote.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/showBlame.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/showBlameHistory.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/showFileHistory.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/showLastQuickPick.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/showQuickBranchHistory.ts Visa fil

@ -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 {

+ 2
- 2
src/commands/showQuickCommitDetails.ts Visa fil

@ -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`);
}
}

+ 2
- 2
src/commands/showQuickCommitFileDetails.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/showQuickCurrentBranchHistory.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/showQuickFileHistory.ts Visa fil

@ -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 {

+ 1
- 1
src/commands/showQuickRepoStatus.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/commands/toggleBlame.ts Visa fil

@ -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`);
}
}

+ 1
- 1
src/extension.ts Visa fil

@ -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.`);
}

+ 1
- 1
src/git/git.ts Visa fil

@ -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;
}

+ 1
- 1
src/git/remotes/factory.ts Visa fil

@ -25,7 +25,7 @@ export class RemoteProviderFactory {
return creator(domain, path);
}
catch (ex) {
Logger.error(ex);
Logger.error(ex, 'RemoteProviderFactory');
return undefined;
}
}

+ 1
- 1
src/gitContentProvider.ts Visa fil

@ -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;
}

+ 3
- 3
src/logger.ts Visa fil

@ -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(' '));
}
}

Laddar…
Avbryt
Spara