Exception: RBS::InvalidExtensionParameterError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rbs/errors.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_name:, extension_name:, extension_params:, class_params:, location:) ⇒ InvalidExtensionParameterError

Returns a new instance of InvalidExtensionParameterError.



30
31
32
33
34
35
36
37
38
# File 'lib/rbs/errors.rb', line 30

def initialize(type_name:, extension_name:, extension_params:, class_params:, location:)
  @type_name = type_name
  @extension_name = extension_name
  @extension_params = extension_params
  @class_params = class_params
  @location = location

  super "#{Location.to_string location}: Expected #{class_params.size} parameters to #{type_name} (#{extension_name}) but has #{extension_params.size} parameters"
end

Instance Attribute Details

#class_paramsObject (readonly)

Returns the value of attribute class_params.



28
29
30
# File 'lib/rbs/errors.rb', line 28

def class_params
  @class_params
end

#extension_nameObject (readonly)

Returns the value of attribute extension_name.



25
26
27
# File 'lib/rbs/errors.rb', line 25

def extension_name
  @extension_name
end

#extension_paramsObject (readonly)

Returns the value of attribute extension_params.



27
28
29
# File 'lib/rbs/errors.rb', line 27

def extension_params
  @extension_params
end

#locationObject (readonly)

Returns the value of attribute location.



26
27
28
# File 'lib/rbs/errors.rb', line 26

def location
  @location
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



24
25
26
# File 'lib/rbs/errors.rb', line 24

def type_name
  @type_name
end

Class Method Details

.check!(type_name:, extension_name:, extension_params:, class_params:, location:) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/rbs/errors.rb', line 40

def self.check!(type_name:, extension_name:, extension_params:, class_params:, location:)
  unless extension_params.size == class_params.size
    raise new(type_name: type_name,
              extension_name: extension_name,
              extension_params: extension_params,
              class_params: class_params,
              location: location)
  end
end