# File lib/rack/showexceptions.rb, line 33
33:     def pretty(env, exception)
34:       req = Rack::Request.new(env)
35:       path = (req.script_name + req.path_info).squeeze("/")
36: 
37:       frames = exception.backtrace.map { |line|
38:         frame = OpenStruct.new
39:         if line =~ /(.*?):(\d+)(:in `(.*)')?/
40:           frame.filename = $1
41:           frame.lineno = $2.to_i
42:           frame.function = $4
43: 
44:           begin
45:             lineno = frame.lineno-1
46:             lines = ::File.readlines(frame.filename)
47:             frame.pre_context_lineno = [lineno-CONTEXT, 0].max
48:             frame.pre_context = lines[frame.pre_context_lineno...lineno]
49:             frame.context_line = lines[lineno].chomp
50:             frame.post_context_lineno = [lineno+CONTEXT, lines.size].min
51:             frame.post_context = lines[lineno+1..frame.post_context_lineno]
52:           rescue
53:           end
54: 
55:           frame
56:         else
57:           nil
58:         end
59:       }.compact
60: 
61:       env["rack.errors"].puts "#{exception.class}: #{exception.message}"
62:       env["rack.errors"].puts exception.backtrace.map { |l| "\t" + l }
63:       env["rack.errors"].flush
64: 
65:       [@template.result(binding)]
66:     end