Hi Andy

What you've suggested - both the NameError and StandardError points - make 
sense. If you fork and patch (with tests), I'll happily merge it in.

Cheers

-- 
Pat

On 09/12/2010, at 7:02 AM, Andy H wrote:

> I'm using the latest thinking_sphinx 1.3.20 and have a concern about
> the load_models method in lib/thinking_sphinx/context.rb.
> 
> Do to a coding error, I have a model that throws a NameError exception
> on load. It looks something like this;
> 
> class User < ActiveRecord::Base
>   validates_length_of :name, :maxiumum => FAT_FINGER # the constant
> FAT_FINGER doesn't exist
> end
> 
> When loading my app (with script/console for example) my models get
> loaded through thinking sphinx, and user.rb raises a NameError on
> FAT_FINGER which load_models rescues and ignores. I think the
> intention of the rescue is to ignore a NameError on the User constant,
> but in this case it's ignoring an error that it shouldn't (IMO).
> 
> Changing the rescue statement like this might do the trick:
> 
>  @@ -64,7 +64,7 @@
>           rescue LoadError
>             model_name.gsub!(/.*[\/\\]/, '').nil? ? next : retry
>           rescue NameError
>  -          next
>  +          $!.name == model_name.camelize ? next : raise
>           rescue StandardError
>             STDERR.puts "Warning: Error loading #{file}"
>           end
> 
> What do you think?
> 
> I'm also a little skeptical about the rescue of StandardError and am
> wondering why that error shouldn't be propagated up as well.
> 
> Thanks!
> 
> Andy
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to