Question

Is there a way to raise a 505 exception with ruby on rails in development?

I would like to testdrive my custom 505 exceptions but found no documentation on how to raise a 505 anywhere.

Was it helpful?

Solution

i am a little confused here. are you talking about a 505 status codes? or are you talking about raising exceptions?

i don't think that there is a 505 exception, so i assume you are talking about HTTP status code version not supported (http://en.wikipedia.org/wiki/List_of_HTTP_status_codes).

it could be as simple as this:

  def index
    render nothing: true, status: 505
  end

if you call an action like that you will get something like this as a response:

curl -I http://hamburg.onruby.dev:5000/
HTTP/1.1 505 HTTP Version not supported
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-UA-Compatible: chrome=1
Content-Type: text/html; charset=utf-8
X-Meta-Request-Version: 0.2.8
Cache-Control: no-cache
Set-Cookie: locale=de; domain=onruby.dev; path=/; expires=Sat, 11 Oct 2014 07:45:52 -0000
X-Request-Id: b8232480-5585-4e99-bc4c-44019e41db6a
X-Runtime: 0.010615
Connection: close
Server: thin 1.5.1 codename Straight Razor
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top