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.



45
46
47
48
49
50
51
52
53
# File 'lib/rbs/errors.rb', line 45

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.



43
44
45
# File 'lib/rbs/errors.rb', line 43

def class_params
  @class_params
end

#extension_nameObject (readonly)

Returns the value of attribute extension_name.



40
41
42
# File 'lib/rbs/errors.rb', line 40

def extension_name
  @extension_name
end

#extension_paramsObject (readonly)

Returns the value of attribute extension_params.



42
43
44
# File 'lib/rbs/errors.rb', line 42

def extension_params
  @extension_params
end

#locationObject (readonly)

Returns the value of attribute location.



41
42
43
# File 'lib/rbs/errors.rb', line 41

def location
  @location
end

#type_nameObject (readonly)

Returns the value of attribute type_name.



39
40
41
# File 'lib/rbs/errors.rb', line 39

def type_name
  @type_name
end

Class Method Details

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



55
56
57
58
59
60
61
62
63
# File 'lib/rbs/errors.rb', line 55

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