Exception: Optimizely::InvalidVariationError
- Defined in:
- lib/optimizely/exceptions.rb
Instance Attribute Summary collapse
-
#variation_id ⇒ Object
readonly
Raised when an invalid variation key or ID is provided.
-
#variation_key ⇒ Object
readonly
Raised when an invalid variation key or ID is provided.
Instance Method Summary collapse
-
#initialize(variation_id: nil, variation_key: nil) ⇒ InvalidVariationError
constructor
A new instance of InvalidVariationError.
Constructor Details
#initialize(variation_id: nil, variation_key: nil) ⇒ InvalidVariationError
Returns a new instance of InvalidVariationError.
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_id ⇒ Object (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_key ⇒ Object (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 |