blah

Ruby code posted
created at 03 Sep 21:41

Edit | Back
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class Sinatra::Base
  def call(env)
    begin
      dup.call!(env)
    rescue => e
      res = [500,{},[]]
      if (ENV['HERBERT_DEBUG'].to_i==1) || (ENV['RACK_ENV'] =~ /debug/) then
        res[1] = {"Content-Type" => "application/json;charset=utf-8"}
        res[2] = ActiveSupport::JSON.encode({
            :error => {
              :code => 1,
              :message => e.to_s,
              :backtrace => e.backtrace
            }
        
          })
      end
      res
    end
  end
end
446 Bytes in 2 ms with coderay