Method: Roda::RodaPlugins::SinatraHelpers::RequestMethods#error
- Defined in:
- lib/roda/plugins/sinatra_helpers.rb
#error(code = 500, body = nil) ⇒ Object
Halt processing and return the error status provided with the given code and optional body. If a single argument is given and it is not an integer, consider it the body and use a 500 status code.
300 301 302 303 304 305 306 307 308 309 |
# File 'lib/roda/plugins/sinatra_helpers.rb', line 300 def error(code=500, body = nil) unless code.is_a?(Integer) body = code code = 500 end response.status = code response.body = body if body halt end |