Sha256: 46d39ecd3ada72bf6e810b0f9d7e245add844a94c49d4a71a9a04b82b0bb4bd5
Contents?: true
Size: 700 Bytes
Versions: 5
Compression:
Stored size: 700 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 not_found do json message: "Not Found" end end end
Version data entries
5 entries across 5 versions & 1 rubygems