You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
738 B
24 lines
738 B
module Admins::ErrorRescueHandler
|
|
extend ActiveSupport::Concern
|
|
|
|
included do
|
|
rescue_from Exception do |e|
|
|
raise e if Rails.env.development?
|
|
|
|
Util.logger_error e
|
|
internal_server_error
|
|
end
|
|
|
|
rescue_from ActionView::MissingTemplate, ActiveRecord::RecordNotFound, with: :render_not_found
|
|
rescue_from ActionController::ParameterMissing do
|
|
render_unprocessable_entity('参数缺失')
|
|
end
|
|
# form validation error
|
|
rescue_from ActiveModel::ValidationError do |ex|
|
|
render_unprocessable_entity(ex.model.errors.full_messages.join(','))
|
|
end
|
|
rescue_from ActiveRecord::RecordInvalid do |ex|
|
|
render_unprocessable_entity(ex.record.errors.full_messages.join(','))
|
|
end
|
|
end
|
|
end |