Sha256: a3c29d8ed72f9430ff3a90209ed905abc2c0d2667e85a4e8a8eb27fd33b192c1
Contents?: true
Size: 867 Bytes
Versions: 1
Compression:
Stored size: 867 Bytes
Contents
# encoding: utf-8 # # Copyright (C) 2011-2012 AdMaster, Inc. module Apimaster::Controllers class Errors < Sinatra::Base superclass.error Apimaster::NormalError do e = env['sinatra.error'] error = [:resource, :code, :field].inject({}) do |err, val| if e.respond_to?(val) and v = e.send(val) err[val] = v end err end messages = {:message => e.message} messages[:errors] = [error] unless error.empty? json messages end superclass.error do if respond_to?(:development?) raise env['sinatra.error'] if development? elsif settings.respond_to?(:development?) raise env['sinatra.error'] if settings.development? end json :message => "Internal Server Error" end superclass.not_found do json message: "Not Found" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
apimaster-0.1.4 | lib/apimaster/controllers/errors.rb |