title: Rails return all 404 and 500 errors as JSON
body: <p>I'm pretty new in rails, and using rails 4.</p>
  
  <p>In my application I want to return all 404 and 500 errors formatted on JSON like that</p>
  
  <pre><code>{
      "status": 404,
      "message": "not found"
  }
  </code></pre>
  
  <p>There is an easy way to do this ? cause I just find solutions to do this with rails 3.x.</p>
  
  <p>Thanks</p>
  
  <p>I trying to do this solution <a href="https://stackoverflow.com/questions/10253366/need-to-return-json-formatted-404-error-in-rails">Need to return JSON-formatted 404 error in Rails</a> but I get <code>error during failsafe response: uninitialized constant ErrorsController</code></p>