Codebase list ruby-fxruby / run/42285a56-c0e4-43cb-8673-97d97da4ddc4/upstream lib / fox16 / exceptions_for_fxerror.rb
run/42285a56-c0e4-43cb-8673-97d97da4ddc4/upstream

Tree @run/42285a56-c0e4-43cb-8673-97d97da4ddc4/upstream (Download .tar.gz)

exceptions_for_fxerror.rb @run/42285a56-c0e4-43cb-8673-97d97da4ddc4/upstreamraw · history · blame

module Fox
  FXWindow.subclasses.each do |klass|
    klass.send(:alias_method, :create_without_parent_created_check, :create)
    klass.send(:define_method, :create) do
      unless parent.created?
        raise RuntimeError, "trying to create window before creating parent window"
      end
      if owner && !owner.created?
        raise RuntimeError, "trying to create window before creating owner window"
      end
      if visual.nil?
        raise RuntimeError, "trying to create window without a visual"
      end
      create_without_parent_created_check
    end
  end
end