Exception: Optimizely::InvalidVariationError

Inherits:
Error
  • Object
show all
Defined in:
lib/optimizely/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variation_id: nil, variation_key: nil) ⇒ InvalidVariationError

Returns a new instance of InvalidVariationError.

Raises:

  • (ArgumentError)


126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/optimizely/exceptions.rb', line 126

def initialize(variation_id: nil, variation_key: nil)
  raise ArgumentError, 'Either variation_id or variation_key must be provided.' if variation_id.nil? && variation_key.nil?
  raise ArgumentError, 'Cannot provide both variation_id and variation_key.' if !variation_id.nil? && !variation_key.nil?

  if variation_id.nil?
    identifier = "key '#{variation_key}'"
    @variation_key = variation_key
  else
    identifier = "id '#{variation_id}'"
    @variation_id = variation_id
  end

  super("Variation #{identifier} is not in datafile.")
end

Instance Attribute Details

#variation_idObject (readonly)

Raised when an invalid variation key or ID is provided



124
125
126
# File 'lib/optimizely/exceptions.rb', line 124

def variation_id
  @variation_id
end

#variation_keyObject (readonly)

Raised when an invalid variation key or ID is provided



124
125
126
# File 'lib/optimizely/exceptions.rb', line 124

def variation_key
  @variation_key
end