Sha256: 9ecb300a409178768aa707c7f044754c141b2617e2fc2b2d0c9ef9adc44b3803

Contents?: true

Size: 844 Bytes

Versions: 92

Compression:

Stored size: 844 Bytes

Contents

module Scrivito
class ErroredWidgetTag < BaseWidgetTag
  attr_reader :error

  def initialize(view, widget, options)
    @error = options.fetch(:error)
    super
  end

  def content
    if view.controller.respond_to?(:on_scrivito_widget_error, true)
      view.controller.__send__(:on_scrivito_widget_error, widget, error)
    else
      handle_render_error(widget, error)
    end
  end

  private

  def description_for_editor
    "Error in #{widget.class.description_for_editor}"
  end

  def handle_render_error(widget, error)
    message = "Rendering widget with ID #{widget.id} and obj_class #{widget.obj_class} for "\
      "obj with ID #{widget.obj.id} failed"
    Warning.error(message, error)

    "We're sorry, but something went wrong. "\
      "If you are the application owner check the logs for more information."
  end
end

end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
scrivito_sdk-1.0.0.rc3 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-1.0.0.rc2 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-1.0.0.rc1 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-0.90.0 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-0.90.0.rc3 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-0.90.0.rc2 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-0.90.0.rc1 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-0.71.2 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-0.71.1 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-0.71.0 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-0.71.0.rc2 lib/scrivito/errored_widget_tag.rb
scrivito_sdk-0.71.0.rc1 lib/scrivito/errored_widget_tag.rb