Sha256: fb9ca6e6c4201de7f6ce68bcf13248c978df95a0cbd44fe04b9573257ab48675

Contents?: true

Size: 751 Bytes

Versions: 6

Compression:

Stored size: 751 Bytes

Contents

module Hyperstack
  class Hotloader
    module AddErrorBoundry
      def self.included(base)
        base.after_error do |*err|
          @err = 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.2 lib/hyperstack/hotloader/add_error_boundry.rb
hyperstack-config-1.0.alpha1.1 lib/hyperstack/hotloader/add_error_boundry.rb
hyperstack-config-1.0.0.pre.alpha1 lib/hyperstack/hotloader/add_error_boundry.rb
hyperstack-config-1.0.alpha1 lib/hyperstack/hotloader/add_error_boundry.rb
hyperstack-config-1.0.pre.alpha1 lib/hyperstack/hotloader/add_error_boundry.rb
hyperstack-config-0.1 lib/hyperstack/hotloader/add_error_boundry.rb