nex3/sass — Issue #200: An ArgumentError on not being able to call a function could be misleading
Author: mcmire
Created: 2011-10-25 17:19:35+00:00
State: open

I just spent a few hours trying to debug why Sass was failing to call a function that I'd added -- why it kept giving an ArgumentError when my function was clearly present in the Sass::Script::Functions module and was accessible. I realized that the ArgumentError wasn't coming from the function call, but from another function call inside the function itself. I noticed that Sass::Script::Funcall#_perform is wrapping the function invocation with a rescue to catch all ArgumentErrors, and while there is a bit of logic to ensure that the error at least involves the function being invoked, it seems like it could be just a little bit smarter. For instance, here was my backtrace:

~~~
/Users/elliot/code/work/mandelbrot/advertiser/lib/extensions/vendor/sass_rails_compat.rb:43:in `root'
/Users/elliot/code/work/mandelbrot/advertiser/lib/extensions/vendor/sass_rails_compat.rb:43:in `_resolve_image_path'
/Users/elliot/code/work/mandelbrot/advertiser/lib/extensions/vendor/sass_rails_compat.rb:39:in `image_url'
/Users/elliot/.rvm/gems/ruby-1.8.7-p330@mb-advertiser/gems/sass-3.1.10/lib/sass/../sass/script/funcall.rb:93:in `send'
/Users/elliot/.rvm/gems/ruby-1.8.7-p330@mb-advertiser/gems/sass-3.1.10/lib/sass/../sass/script/funcall.rb:93:in `_perform'
........
~~~

So perhaps the logic could be changed so that if there is anything above "funcall.rb" in the backtrace then the error is re-raised? What do you think?