Only set `v:errmsg` for real errors, not exceptions.
M autoload/lawrencium.vim +16 -11
@@ 68,6 68,11 @@ endfunction
 
 " 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 @@ endfunction
 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 @@ endfunction
 
 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 @@ function! s:Buffer.DefineCommand(name, .
         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 @@ endfunction
 
 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 @@ endfunction
 
 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 @@ function! s:Buffer.MoveToFirstWindow() d
         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 @@ let s:lawrencium_file_customoptions = {}
 
 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 @@ function! lawrencium#read_lawrencium_fil
     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.

          
M autoload/lawrencium/diff.vim +1 -1
@@ 127,7 127,7 @@ function! s:HgDiff_DiffThis(diff_id) abo
     " 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('%'))

          
M autoload/lawrencium/log.vim +1 -1
@@ 167,7 167,7 @@ function! s:HgLog_GetSelectedRev(...) ab
     " 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

          
M autoload/lawrencium/record.vim +2 -2
@@ 70,7 70,7 @@ function! lawrencium#record#HgRecord_Exe
     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 @@ function! lawrencium#record#HgRecord_Cle
     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

          
M autoload/lawrencium/status.vim +1 -1
@@ 85,7 85,7 @@ function! lawrencium#status#HgStatusRefr
         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.