Skip to content

Commit

Permalink
improve errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rcarver committed Feb 26, 2013
1 parent e6086fb commit 5fb2cbb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/levels/setup.rb
Expand Up @@ -100,7 +100,7 @@ def input
when :ruby then Levels::Input::Ruby.new(source, *args)
when :json then Levels::Input::JSON.new(source)
when :yaml then Levels::Input::YAML.new(source)
else raise ArgumentError, "Could not identify the format (#{format.inspect})"
else raise ArgumentError, "Could not identify the format: #{format.inspect}"
end
end

Expand All @@ -116,12 +116,14 @@ def identify
when ".rb" then [:ruby, pn.read, pn.to_s, 1]
when ".json" then [:json, pn.read]
when ".yaml", ".yml" then [:yaml, pn.read]
else raise ArgumentError, "Could not identify the file type: #{pn.extname}"
end
else
case @source
when /\A\w*{/ then [:json, @source]
when /\A---$/ then [:yaml, @source]
when /\A\w*group/ then [:ruby, @source, "Code from String", 1]
else raise ArgumentError, "Could not identify the source: #{@source.inspect}"
end
end
end
Expand Down

0 comments on commit 5fb2cbb

Please sign in to comment.