Created
August 18, 2011 23:51
-
-
Save samstokes/1155575 to your computer and use it in GitHub Desktop.
Proposed API for controller error reporting
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
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