Skip to content

Commit

Permalink
better tool instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
greatseth committed Nov 18, 2009
1 parent 8723d07 commit 7edfcf1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/rvideo/tools/abstract_tool.rb
Expand Up @@ -8,10 +8,13 @@ class AbstractTool
def self.assign(cmd, options = {})
tool_name = cmd.split(" ").first
begin
tool = "RVideo::Tools::#{tool_name.underscore.classify}".constantize.send(:new, cmd, options)
# rescue NameError, /uninitialized constant/
# raise TranscoderError::UnknownTool, "The recipe tried to use the '#{tool_name}' tool, which does not exist."
rescue => e
tool_class_name = tool_name.underscore.classify
tool = RVideo::Tools.const_get(tool_class_name).new(cmd, options)
rescue NameError => e
raise TranscoderError::UnknownTool,
"The recipe tried to use #{tool_name.inspect}, " +
"which expands to #{tool_class_name.inspect}, which does not exist. \n#{e.message}"
rescue Object => e
RVideo.logger.info e.message
RVideo.logger.info e.backtrace.join("\n")
raise e
Expand Down

0 comments on commit 7edfcf1

Please sign in to comment.