Sha256: b05a2947d8c63d9cc00d077d1e1c5e415156e8d397a61f737bad2e6046284493

Contents?: true

Size: 818 Bytes

Versions: 6

Compression:

Stored size: 818 Bytes

Contents

module Hyperstack
  class Hotloader
    module AddErrorBoundry
      def self.included(base)
        base.after_error do |*err|
          @err = Hyperstack::Internal::Component::RescueWrapper.after_error_args || err
          Hyperstack::Component.force_update!
        end
        base.define_method :render do
          @err ? parse_display_and_clear_error : top_level_render
        end
      end

      def parse_display_and_clear_error
        e = @err[0]
        component_stack = @err[1]['componentStack'].split("\n ")
        @err = nil
        display_error(e, component_stack)
      end

      def display_error(e, component_stack)
        DIV do
          DIV { "Uncaught error: #{e}" }
          component_stack.each do |line|
            DIV { line }
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hyperstack-config-1.0.alpha1.8 lib/hyperstack/hotloader/add_error_boundry.rb
hyperstack-config-1.0.alpha1.7 lib/hyperstack/hotloader/add_error_boundry.rb
hyperstack-config-1.0.alpha1.6 lib/hyperstack/hotloader/add_error_boundry.rb
hyperstack-config-1.0.alpha1.5 lib/hyperstack/hotloader/add_error_boundry.rb
hyperstack-config-1.0.alpha1.4 lib/hyperstack/hotloader/add_error_boundry.rb
hyperstack-config-1.0.alpha1.3 lib/hyperstack/hotloader/add_error_boundry.rb