Class: Epuber::Server::ShowExceptions

Inherits:
Sinatra::ShowExceptions
  • Object
show all
Defined in:
lib/epuber/server.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/epuber/server.rb', line 34

def call(env)
  e = env['sinatra.error']

  if prefers_plain_text?(env)
    content_type = 'text/plain'
    body = [dump_exception(e)]
  else
    content_type = 'text/html'
    body = pretty(env, e)
  end

  body = [body] unless body.is_a?(Array)

  [500, { 'Content-Type' => content_type,
          'Content-Length' => Rack::Utils.bytesize(body.join).to_s },
   body]
end