Sha256: 64bd81b5e6a867c8afeeb7b63f96f835332fc56ab41158e7dfdc5fbcb72ddd20
Contents?: true
Size: 711 Bytes
Versions: 4
Compression:
Stored size: 711 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 raise env['sinatra.error'] if development? json :message => "Internal Server Error" end superclass.not_found do json message: "Not Found" end end end
Version data entries
4 entries across 4 versions & 1 rubygems