vereto-api/app/controllers/concerns/exception_handler.rb
2018-02-16 11:52:56 +00:00

14 lines
No EOL
322 B
Ruby

module ExceptionHandler
extend ActiveSupport::Concern
included do
rescue_from ActiveRecord::RecordNotFound do |e|
json_response({ message: e.message}, :not_found)
end
rescue_from ActiveRecord::RecordInvalid do |e|
json_response({ message: e.message}, :unprocessable_entity)
end
end
end