title: Rails 4.2 ActionController:BadRequest custom error message
body: <p>I want to return from my controller if either a validation failed or a parameter is missing with <code>400 - bad request</code>. So in my controller if have </p>
  
  <pre><code>if params["patch"].nil? then
    raise ActionController::BadRequest.new( "The Json body needs to be wrapped inside a \"Patch\" key")
  end
  </code></pre>
  
  <p>and i catch this error in my Application Controller with:</p>
  
  <pre><code>rescue_from ActionController::BadRequest, with: :bad_request
  
  
  def bad_request(exception)
    render status: 400, json: {:error =&gt; exception.message}.to_json
  end
  </code></pre>
  
  <p>But it seems like i cannot add custom messages when raising <code>ActionController::BadRequest</code>. Because when passing an invalid body the response is only <code>{"error":"ActionController::BadRequest"}</code> and not the hash i provided.</p>
  
  <p>In the console i get the same behaviour.  <code>raise ActiveRecord::RecordNotFound, "foo"</code>  indeed raises <code>ActiveRecord::RecordNotFound: foo</code>. </p>
  
  <p>But <code>raise ActionController::BadRequest, "baa"</code>  results in </p>
  
  <p><code>ActionController::BadRequest: ActionController::BadRequest</code></p>
  
  <p>How can i add custom messages to the <code>BadRequest</code> exception?</p>