Module: ForestErrorsHelper
- Defined in:
- app/helpers/forest_errors_helper.rb
Instance Method Summary collapse
-
#forest_admin_error(error, options = {}) ⇒ Object
Display errors that are only visible to admin users.
Instance Method Details
#forest_admin_error(error, options = {}) ⇒ Object
Display errors that are only visible to admin users
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/helpers/forest_errors_helper.rb', line 3 def forest_admin_error(error, = {}) if Rails.env.production? if current_user&.admin? logger.error("[Forest] forest_admin_error") logger.error(error.) logger.error(error.backtrace.join("\n")) = [] << "Error on #{Rails.application.class.parent.to_s.titleize}\n" << "Path: #{request.fullpath.force_encoding('utf-8')}\n" << "#{error.}\n" << error.backtrace.first(20).join("\n") visible_errors_for_admin = [] visible_errors_for_admin << .fetch(:message, "Warning: this code block has errors and is not visible to the public.\nYou are seeing this message because you are an admin.\n") visible_errors_for_admin << mail_to('mailto:[email protected]', "Click here to email this error to the developers.\n", subject: "Error on #{Rails.application.class.parent.to_s.titleize} - #{request.path.force_encoding('utf-8')}", body: .join("\n").html_safe, target: '_blank') visible_errors_for_admin << "#{error.}\n" visible_errors_for_admin << error.backtrace.join("\n") content_tag :pre, class: 'admin-error-message' do visible_errors_for_admin.join("\n").html_safe end end else raise error end end |