File: errors.rb

package info (click to toggle)
ruby-gitlab-experiment 0.9.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 260 kB
  • sloc: ruby: 1,202; makefile: 7
file content (29 lines) | stat: -rw-r--r-- 853 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

module Gitlab
  class Experiment
    Error = Class.new(StandardError)
    InvalidRolloutRules = Class.new(Error)
    UnregisteredExperiment = Class.new(Error)
    ExistingBehaviorError = Class.new(Error)
    BehaviorMissingError = Class.new(Error)

    class NestingError < Error
      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
    end
  end
end