14 lines
322 B
Ruby
14 lines
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
|