Created
February 2, 2010 01:47
-
-
Save alexch/292270 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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