Skip to content

Instantly share code, notes, and snippets.

@samstokes
Created August 18, 2011 23:51
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 samstokes/1155575 to your computer and use it in GitHub Desktop.
Save samstokes/1155575 to your computer and use it in GitHub Desktop.
Proposed API for controller error reporting
class TestController < ApplicationController
report RuntimeError, :status => 411, :error_code => :oh_noes
report ArgumentError, :status => 407, :error_code => :eeep do |exception, report|
report[:nartiploom] = Time.now
report[:banditry] = exception.class.name
end
report IndexError, :status => 404
def index
case params[:boom]
when 'arg'
raise ArgumentError, 'arg'
when 'fish'
{}.fetch 5
else
raise 'oops'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment