Permalink
Browse files

Add descriptive messages to the exceptions thrown by cgi_methods. Closes

 #6091.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5066 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 840b576 commit 9d9ac01c7ddf1d3af1ee2151e2977d3ee9e48294 @seckar seckar committed Sep 7, 2006
Showing with 10 additions and 2 deletions.
  1. +2 −0 actionpack/CHANGELOG
  2. +8 −2 actionpack/lib/action_controller/cgi_ext/cgi_methods.rb
View
@@ -1,5 +1,7 @@
*SVN*
+* Add descriptive messages to the exceptions thrown by cgi_methods. Closes #6091. [Nicholas Seckar]
+
* Update JavaScriptGenerator#show/hide/toggle/remove to new Prototype syntax for multiple ids, #6068 [petermichaux@gmail.com]
* Update UrlWriter to support :only_path. [Nicholas Seckar, Dave Thomas]
@@ -156,9 +156,9 @@ def post_key_check(key)
# Add a container to the stack.
#
def container(key, klass)
- raise TypeError if top.is_a?(Hash) && top.key?(key) && ! top[key].is_a?(klass)
+ type_conflict! klass, top[key] if top.is_a?(Hash) && top.key?(key) && ! top[key].is_a?(klass)
value = bind(key, klass.new)
- raise TypeError unless value.is_a?(klass)
+ type_conflict! klass, value unless value.is_a?(klass)
push(value)
end
@@ -190,5 +190,11 @@ def bind(key, value)
return value
end
+
+ def type_conflict!(klass, value)
+ raise TypeError, "Conflicting types for parameter containers
+ Expected an instance of #{klass}, but found found one of #{value.class}"
+ end
+
end
end

0 comments on commit 9d9ac01

Please sign in to comment.