Sha256: 6053fef00dfe33baa4abc79dd3422187be6479c746e10be31625bff0f6f22ea6
Contents?: true
Size: 789 Bytes
Versions: 2
Compression:
Stored size: 789 Bytes
Contents
module Napa module GrapeExtenders def self.extended(modified_class) # when extended, set the exceptions to handle # if AR is being used, rescue from common AR errors if defined?(::ActiveRecord) modified_class.rescue_from ::ActiveRecord::RecordNotFound do |e| err = Napa::JsonError.new(:record_not_found, 'record not found') Napa::Logger.logger.debug Napa::Logger.response(404, {}, err) rack_response(err.to_json, 404) end modified_class.rescue_from ::ActiveRecord::RecordInvalid do |e| err = Napa::JsonError.new(:unprocessable_entity, e.message) Napa::Logger.logger.debug Napa::Logger.response(422, {}, err) rack_response(err.to_json, 422) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
napa-0.4.0 | lib/napa/grape_extenders.rb |
napa-0.3.0 | lib/napa/grape_extenders.rb |