Method: Ocular::Inputs::HTTP::Input#handle_exception!

Defined in:
lib/ocular/inputs/http_input.rb

#handle_exception!(context, error) ⇒ Object



485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
# File 'lib/ocular/inputs/http_input.rb', line 485

def handle_exception!(context, error)
    context.env['error'] = error

    if error.respond_to? :http_status
        context.response.status = error.http_status

        if error.respond_to? :to_s
            str = error.to_s
            if !str.end_with?("\n")
                str += "\n"
            end
            context.response.body = str
        end
    else
        context.response.status = 500
        puts "Internal Server Error: #{error}"
        puts error.backtrace
    end
end