Skip to content

Instantly share code, notes, and snippets.

@kenichi
Created June 21, 2012 23:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenichi/2969137 to your computer and use it in GitHub Desktop.
Save kenichi/2969137 to your computer and use it in GitHub Desktop.
error catching
#!/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