|
|
|
@ -2,6 +2,10 @@ module ControllerRescueHandler
|
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
|
|
included do
|
|
|
|
|
rescue_from Exception do |e|
|
|
|
|
|
logger.error e
|
|
|
|
|
render json: {status: -1, message: e.message}
|
|
|
|
|
end
|
|
|
|
|
# rescue_from ActionView::MissingTemplate, with: :object_not_found
|
|
|
|
|
# rescue_from ActiveRecord::RecordNotFound, with: :object_not_found
|
|
|
|
|
rescue_from Educoder::TipException, with: :tip_show
|
|
|
|
@ -15,9 +19,5 @@ module ControllerRescueHandler
|
|
|
|
|
rescue_from ActiveRecord::RecordInvalid do |ex|
|
|
|
|
|
render_error(ex.record.errors.full_messages.join(','))
|
|
|
|
|
end
|
|
|
|
|
rescue_from Exception do |e|
|
|
|
|
|
logger.error e
|
|
|
|
|
render json: {status: -1, message: e.message}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|