diff options
author | Roque Pinel <repinel@gmail.com> | 2015-07-18 18:40:47 -0400 |
---|---|---|
committer | Roque Pinel <repinel@gmail.com> | 2015-07-18 18:48:41 -0400 |
commit | 780af27bf9135be8cc4ae1a9c1ce4c9b4d15fd4b (patch) | |
tree | 1f49133cf02551eae7cff44260c92d03d0db10e5 /actionpack/lib | |
parent | 3f1c5d39c01e13bcf9e34865f00ded56a3a321fc (diff) | |
download | rails-780af27bf9135be8cc4ae1a9c1ce4c9b4d15fd4b.tar.gz rails-780af27bf9135be8cc4ae1a9c1ce4c9b4d15fd4b.tar.bz2 rails-780af27bf9135be8cc4ae1a9c1ce4c9b4d15fd4b.zip |
Fix exception overwritten for parameters fetch method
When executing an `ActionController::Parameters#fetch` with a block
that raises a `KeyError` the raised `KeyError` will be rescued and
converted to an `ActionController::ParameterMissing` exception,
covering up the original exception.
[Jonas Schubert Erlandsson & Roque Pinel]
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/metal/strong_parameters.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/metal/strong_parameters.rb b/actionpack/lib/action_controller/metal/strong_parameters.rb index 06d625e4d5..cf6a64009f 100644 --- a/actionpack/lib/action_controller/metal/strong_parameters.rb +++ b/actionpack/lib/action_controller/metal/strong_parameters.rb @@ -380,11 +380,15 @@ module ActionController def fetch(key, *args, &block) convert_hashes_to_parameters( key, - @parameters.fetch(key, *args, &block), + @parameters.fetch(key) { + if block_given? + yield + else + args.fetch(0) { raise ActionController::ParameterMissing.new(key) } + end + }, false ) - rescue KeyError - raise ActionController::ParameterMissing.new(key) end # Returns a new <tt>ActionController::Parameters</tt> instance that |