Exception: Optimizely::InvalidExperimentError

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(experiment_id: nil, experiment_key: nil) ⇒ InvalidExperimentError

Returns a new instance of InvalidExperimentError.

Raises:

  • (ArgumentError)


91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/optimizely/exceptions.rb', line 91

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

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

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

Instance Attribute Details

#experiment_idObject (readonly)

Raised when an invalid experiment key is provided



89
90
91
# File 'lib/optimizely/exceptions.rb', line 89

def experiment_id
  @experiment_id
end

#experiment_keyObject (readonly)

Raised when an invalid experiment key is provided



89
90
91
# File 'lib/optimizely/exceptions.rb', line 89

def experiment_key
  @experiment_key
end