Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

raise custom exception when invalid objects found in tree

So we can rescue something more specific than RuntimeError to detect
this situation.

Signed-off-by: rick <technoweenie@gmail.com>
  • Loading branch information...
commit 8f203a16cd0fc2d6a5c1aa8de4ef8d05499e0d2f 1 parent 3073a5c
@rtomayko rtomayko authored technoweenie committed
Showing with 5 additions and 2 deletions.
  1. +3 −0  lib/grit/errors.rb
  2. +1 −1  lib/grit/tree.rb
  3. +1 −1  test/test_tree.rb
View
3  lib/grit/errors.rb
@@ -4,4 +4,7 @@ class InvalidGitRepositoryError < StandardError
class NoSuchPathError < StandardError
end
+
+ class InvalidObjectType < StandardError
+ end
end
View
2  lib/grit/tree.rb
@@ -74,7 +74,7 @@ def content_from_string(repo, text)
when "commit"
Submodule.create(repo, :id => id, :mode => mode, :name => name)
else
- raise "Invalid type: #{type}"
+ raise Grit::InvalidObjectType, type
end
end
View
2  test/test_tree.rb
@@ -59,7 +59,7 @@ def test_content_from_string_tree_should_return_submodule
end
def test_content_from_string_invalid_type_should_raise
- assert_raise(RuntimeError) do
+ assert_raise(Grit::InvalidObjectType) do
@t.content_from_string(nil, "040000 bogus 650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44 test")
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.