mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix error message documentation
This commit is contained in:
parent
34956f7422
commit
80f46653e2
2 changed files with 3 additions and 3 deletions
|
@ -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 @@ module ActiveSupport
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue