# HG changeset patch # User Ludovic Chabant # Date 1481175198 28800 # Wed Dec 07 21:33:18 2016 -0800 # Node ID 4d5f4233b04ecc052d9d46a5dab1f4155e50735f # Parent 652a6f5df0f3a204fc2c23418e1f7b4d62efa414 Only set `v:errmsg` for real errors, not exceptions. diff --git a/autoload/lawrencium.vim b/autoload/lawrencium.vim --- a/autoload/lawrencium.vim +++ b/autoload/lawrencium.vim @@ -68,6 +68,11 @@ " Throw a Lawrencium exception message. function! lawrencium#throw(message) + throw "lawrencium: " . a:message +endfunction + +" Throw a Lawrencium exception message and set Vim's error message. +function! lawrencium#throwerr(message) let v:errmsg = "lawrencium: " . a:message throw v:errmsg endfunction @@ -253,7 +258,7 @@ function! s:HgRepo.GetFullPath(path) abort let l:root_dir = self.root_dir if lawrencium#isabspath(a:path) - call lawrencium#throw("Expected relative path, got absolute path: " . a:path) + call lawrencium#throwerr("Expected relative path, got absolute path: " . a:path) endif return lawrencium#normalizepath(l:root_dir . a:path) endfunction @@ -459,7 +464,7 @@ function! s:Buffer.DefineCommand(name, ...) dict abort if a:0 == 0 - call lawrencium#throw("Not enough parameters for s:Buffer.DefineCommands()") + call lawrencium#throwerr("Not enough parameters for s:Buffer.DefineCommands()") endif if a:0 == 1 let l:flags = '' @@ -469,10 +474,10 @@ let l:cmd = a:2 endif if has_key(self.cmd_names, a:name) - call lawrencium#throw("Command '".a:name."' is already defined in buffer ".self.nr) + call lawrencium#throwerr("Command '".a:name."' is already defined in buffer ".self.nr) endif if bufnr('%') != self.nr - call lawrencium#throw("You must move to buffer ".self.nr."first before defining local commands") + call lawrencium#throwerr("You must move to buffer ".self.nr."first before defining local commands") endif let self.cmd_names[a:name] = 1 let l:real_flags = '' @@ -484,10 +489,10 @@ function! s:Buffer.DeleteCommand(name) dict abort if !has_key(self.cmd_names, a:name) - call lawrencium#throw("Command '".a:name."' has not been defined in buffer ".self.nr) + call lawrencium#throwerr("Command '".a:name."' has not been defined in buffer ".self.nr) endif if bufnr('%') != self.nr - call lawrencium#throw("You must move to buffer ".self.nr."first before deleting local commands") + call lawrencium#throwerr("You must move to buffer ".self.nr."first before deleting local commands") endif execute 'delcommand '.a:name call remove(self.cmd_names, a:name) @@ -495,7 +500,7 @@ function! s:Buffer.DeleteCommands() dict abort if bufnr('%') != self.nr - call lawrencium#throw("You must move to buffer ".self.nr."first before deleting local commands") + call lawrencium#throwerr("You must move to buffer ".self.nr."first before deleting local commands") endif for name in keys(self.cmd_names) execute 'delcommand '.name @@ -509,7 +514,7 @@ if a:0 > 0 && a:1 == 0 return 0 endif - call lawrencium#throw("No windows currently showing buffer ".self.nr) + call lawrencium#throwerr("No windows currently showing buffer ".self.nr) endif execute l:win_nr.'wincmd w' return 1 @@ -673,7 +678,7 @@ function! lawrencium#add_reader(action, callback, ...) abort if has_key(s:lawrencium_file_readers, a:action) - call lawrencium#throw("Lawrencium file '".a:action."' has alredy been registered.") + call lawrencium#throwerr("Lawrencium file '".a:action."' has alredy been registered.") endif let s:lawrencium_file_readers[a:action] = function(a:callback) if a:0 && a:1 @@ -685,10 +690,10 @@ call lawrencium#trace("Reading Lawrencium file: " . a:path) let l:path_parts = lawrencium#parse_lawrencium_path(a:path) if l:path_parts['root'] == '' - call lawrencium#throw("Can't get repository root from: " . a:path) + call lawrencium#throwerr("Can't get repository root from: " . a:path) endif if !has_key(s:lawrencium_file_readers, l:path_parts['action']) - call lawrencium#throw("No registered reader for action: " . l:path_parts['action']) + call lawrencium#throwerr("No registered reader for action: " . l:path_parts['action']) endif " Call the registered reader. diff --git a/autoload/lawrencium/diff.vim b/autoload/lawrencium/diff.vim --- a/autoload/lawrencium/diff.vim +++ b/autoload/lawrencium/diff.vim @@ -127,7 +127,7 @@ " It's needed because `diffoff` reverts those settings to their default " values, instead of their previous ones. if &diff - call lawrencium#throw("Calling diffthis too late on a buffer!") + call lawrencium#throwerr("Calling diffthis too late on a buffer!") return endif call lawrencium#trace('Enabling diff mode on ' . bufname('%')) diff --git a/autoload/lawrencium/log.vim b/autoload/lawrencium/log.vim --- a/autoload/lawrencium/log.vim +++ b/autoload/lawrencium/log.vim @@ -167,7 +167,7 @@ " Behold, Vim's look-ahead regex syntax again! WTF. let l:rev = matchstr(l:line, '\v^(\d+)(\:)@=') if l:rev == '' - call lawrencium#throw("Can't parse revision number from line: " . l:line) + call lawrencium#throwerr("Can't parse revision number from line: " . l:line) endif return l:rev endfunction diff --git a/autoload/lawrencium/record.vim b/autoload/lawrencium/record.vim --- a/autoload/lawrencium/record.vim +++ b/autoload/lawrencium/record.vim @@ -70,7 +70,7 @@ endif if !exists('b:lawrencium_record_for') - call lawrencium#throw("This doesn't seem like a record buffer, something's wrong!") + call lawrencium#throwerr("This doesn't seem like a record buffer, something's wrong!") endif if b:lawrencium_record_for == '%' " Switch to the 'recording' buffer's window. @@ -149,7 +149,7 @@ let l:buf_obj = lawrencium#buffer_obj(a:buf_nr) call l:buf_obj.MoveToFirstWindow() if !exists('b:lawrencium_record_for') || b:lawrencium_record_for != '%' - call lawrencium#throw("Cleaning up something else than the original buffer ". + call lawrencium#throwerr("Cleaning up something else than the original buffer ". \"for a record operation. That's suspiciously incorrect! ". \"Aborting.") endif diff --git a/autoload/lawrencium/status.vim b/autoload/lawrencium/status.vim --- a/autoload/lawrencium/status.vim +++ b/autoload/lawrencium/status.vim @@ -85,7 +85,7 @@ let l:win_nr = bufwinnr(a:1) call lawrencium#trace("Switching back to status window ".l:win_nr) if l:win_nr < 0 - call lawrencium#throw("Can't find the status window anymore!") + call lawrencium#throwerr("Can't find the status window anymore!") endif execute l:win_nr . 'wincmd w' " Delete everything in the buffer, and re-read the status into it.