Variable Interpolation in Vimscript catch clause
I'm working on a small testing framework for vim plugins and am trying to
implement a function that calls a user-specified function and checks if
the function calls exceptions when needed. The problem I'm having is that
I can't get the vim catch clause to accept a string passed in to the
testing function.
Here's a simplified version of what I'd like.
function! TestException(fx, arguments, exception)
let Fx = function(a:fx)
try
call call(Fx, a:arguments)
catch a:exception " Here's the problem line
return 1
endtry
return 0
endfunction
This function works fine if I hard code the exception into the catch clause
catch /E740/or whatever, but it doesn't interpolate the passed in
variable. I've tried executing the whole block in an 'execute' string, but
that doesn't seem to work either.
So far I've tabled this issue and just allowed it to catch any exception
and trust the caller to understand the limitation of that kind of general
test.
So, does anybody know how to fix this, or, does anybody know of a way to
figure out which exception was thrown after it's caught so I can compare
that to the argument after the fact?
No comments:
Post a Comment