Permalink
Browse files

improve errors

  • Loading branch information...
1 parent e6086fb commit 5fb2cbb30264a69969785828f101c33dbcab2659 @rcarver committed Feb 26, 2013
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/levels/setup.rb
View
@@ -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
@@ -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

0 comments on commit 5fb2cbb

Please sign in to comment.