Module: Sinatra::Error
- Defined in:
- lib/sinatra/error.rb
Instance Method Summary collapse
Instance Method Details
#encode(message, format) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/sinatra/error.rb', line 3 def encode(, format) if format == :json = .is_a?(Hash) ? : { :error => } .to_json else .is_a?(Hash) ? .to_json : end end |
#error!(message, status = 403, format = :json) ⇒ Object
12 13 14 |
# File 'lib/sinatra/error.rb', line 12 def error!(, status = 403, format = :json) throw(:halt, [status, encode(, format)]) # uncaught throw :halt (ArgumentError) end |