Created
June 21, 2012 23:02
-
-
Save kenichi/2969137 to your computer and use it in GitHub Desktop.
error catching
This file contains 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
#!/usr/bin/env ruby | |
require 'sinatra' | |
require 'sinatra/namespace' | |
configure do | |
disable :raise_errors | |
disable :show_exceptions | |
end | |
error do | |
halt 200, 'boooo error!' | |
end | |
not_found do | |
halt 200, "yayyyy don't know about that." | |
end | |
get '/' do | |
raise 'foo' | |
@foo = 'bar' | |
haml :index | |
end | |
namespace '/foo' do | |
error do | |
halt 200, 'hi there, error!' | |
end | |
not_found do | |
halt 200, "worrrrrrd, don't know about that." | |
end | |
get '/' do | |
raise 'bar' | |
end | |
namespace '/bar' do | |
get '/?' do | |
raise 'bar' | |
end | |
end | |
end | |
__END__ | |
@@ layout | |
%html | |
= yield | |
@@ index | |
%div.title Hello world. foo is |= @foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment