Method: Sinatra::Base.error
- Defined in:
- lib/sinatra/base.rb
.error(*codes, &block) ⇒ Object
Define a custom error handler. Optionally takes either an Exception class, or an HTTP status code to specify which errors should be handled.
1402 1403 1404 1405 1406 1407 1408 |
# File 'lib/sinatra/base.rb', line 1402 def error(*codes, &block) args = compile! 'ERROR', /.*/, block codes = codes.flat_map(&method(:Array)) codes << Exception if codes.empty? codes << Sinatra::NotFound if codes.include?(404) codes.each { |c| (@errors[c] ||= []) << args } end |