[Nitro] Better diagnostics for gen

gabriele renzi surrender_it at yahoo.it
Tue Apr 25 07:23:00 EDT 2006


Hi people,

I noticed working on a friend's box that the current exception handling 
tends to swallow too much information.

The problem is that in gen/bin/gen the block:

begin
   require "gen/#{generator}/gen.rb"
rescue LoadError
   puts 'Cannot load the specified generator!'
   exit 1
end

won't notice the difference between a non existing generator and a 
LoadError raised in the generator file (friend's problem was related to 
a corrupted install of facets).


Maybe there could be a more explanative message, i.e.

begin
   path="gen/#{generator}/gen.rb"
   require path
rescue LoadError =>e
   if e.message[/#{path}$/]
    reason=  %{\tno such generator "#{generator}"}
   else
     reason= %{\tunmet dependency loading "#{path}":\n\t#{e.message}}
   end
   puts "Cannot load the specified generator!"
   puts reason
   exit 1
end

I think spitting out the available generators is not meaningful as of 
now, but if Brian's suggestion of model/scaffold generators is going to 
be applied I think it would be nice to also show the list in the first 
case.




More information about the Nitro-general mailing list