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



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

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

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

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