Skip to content

Instantly share code, notes, and snippets.

@alexch
Created February 2, 2010 01:47
Show Gist options
  • Save alexch/292270 to your computer and use it in GitHub Desktop.
Save alexch/292270 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra/base'
class Fail < Sinatra::Base
error do
"Failed"
end
get "/" do
raise "OMG"
end
end
if __FILE__ == $0
Fail.run! :host => 'localhost', :port => 4567
end
# This is incorrect:
#
# $ ruby fail.rb
# == Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Thin
# >> Thin web server (v1.2.4 codename Flaming Astroboy)
# >> Maximum connections set to 1024
# >> Listening on localhost:4567, CTRL+C to stop
# !! Unexpected error while processing request: OMG
# !! Unexpected error while processing request: OMG
# !! Unexpected error while processing request: OMG
#
# ...and the page is not at all friendly: in firefox it's empty, and in Safari it says "Safari can’t open the page “http://localhost:4567/” because the server unexpectedly dropped the connection."
require 'rubygems'
require 'sinatra'
error do
"Failed"
end
get "/" do
raise "OMG"
end
# This is correct behavior:
#
# $ ruby fail_ok.rb
# == Sinatra/0.9.4 has taken the stage on 4567 for development with backup from Thin
# >> Thin web server (v1.2.4 codename Flaming Astroboy)
# >> Maximum connections set to 1024
# >> Listening on 0.0.0.0:4567, CTRL+C to stop
# RuntimeError - OMG:
# fail_ok.rb:9:in `GET /'
# fail_ok.rb:8RuntimeError: OMG
# fail_ok.rb:9:in `GET /'
# /Library/Ruby/Gems/1.8/gems/sinatra-0.9.4/lib/sinatra/base.rb:779:in `call'
# /Library/Ruby/Gems/1.8/gems/sinatra-0.9.4/lib/sinatra/base.rb:779:in `route'
# /Library/Ruby/Gems/1.8/gems/sinatra-0.9.4/lib/sinatra/base.rb:474:in `instance_eval'
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment