Class: Gitlab::Experiment::NestingError

Inherits:
Error
  • Object
show all
Defined in:
lib/gitlab/experiment/errors.rb

Instance Method Summary collapse

Constructor Details

#initialize(experiment:, nested_experiment:) ⇒ NestingError

Returns a new instance of NestingError.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/gitlab/experiment/errors.rb', line 12

def initialize(experiment:, nested_experiment:)
  messages = []
  experiments = [nested_experiment, experiment]

  callers = caller_locations
  callers.select.with_index do |caller, index|
    next if caller.label != 'experiment'

    messages << "  #{experiments[messages.length].name} initiated by #{callers[index + 1]}"
  end

  messages << ["unable to nest #{nested_experiment.name} within #{experiment.name}:"]

  super(messages.reverse.join("\n"))
end