Capture ActionController::BadRequest before processing action

  * In Rails 4.2, request#formats never raises BadRequest
  * In Rails 4.1 and earlier, request#formats raises it for the first
    time, won't raise after the first call

Related issues:

  * https://github.com/rails/rails/issues/11502
  * https://github.com/rails/rails/pull/13999