提交 80f46653 编写于 作者: M Manoj M J

Fix error message documentation

上级 34956f74
......@@ -24,7 +24,7 @@ module ActiveSupport
# To raise an exception when the value is blank, append a
# bang to the key name, like:
#
# h.dog! # => raises KeyError: key not found: :dog
# h.dog! # => raises KeyError: :dog is blank
#
class OrderedOptions < Hash
alias_method :_get, :[] # preserve the original #[] method
......@@ -46,7 +46,7 @@ def method_missing(name, *args)
bangs = name_string.chomp!("!")
if bangs
fetch(name_string.to_sym).presence || raise(KeyError.new("#{name_string} is blank."))
fetch(name_string.to_sym).presence || raise(KeyError.new(":#{name_string} is blank"))
else
self[name_string]
end
......
......@@ -1049,7 +1049,7 @@ If you want an exception to be raised when some key is blank, use the bang
version:
```ruby
Rails.application.credentials.some_api_key! # => raises KeyError: key not found: :some_api_key
Rails.application.credentials.some_api_key! # => raises KeyError: :some_api_key is blank
```
Additional Resources
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册