File: errors.rb

package info (click to toggle)
ruby-scientist 1.6.5-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 292 kB
  • sloc: ruby: 1,239; sh: 23; makefile: 4
file content (38 lines) | stat: -rw-r--r-- 836 bytes parent folder | download | duplicates (3)
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
30
31
32
33
34
35
36
37
38
module Scientist

  # Smoking in the bathroom and/or sassing.
  class BadBehavior < StandardError
    attr_reader :experiment
    attr_reader :name

    def initialize(experiment, name, message)
      @experiment = experiment
      @name = name

      super message
    end
  end

  class BehaviorMissing < BadBehavior
    def initialize(experiment, name)
      super experiment, name,
        "#{experiment.name} missing #{name} behavior"
    end
  end

  class BehaviorNotUnique < BadBehavior
    def initialize(experiment, name)
      super experiment, name,
        "#{experiment.name} already has #{name} behavior"
    end
  end

  class NoValue < StandardError
    attr_reader :observation

    def initialize(observation)
      @observation = observation
      super "#{observation.name} didn't return a value"
    end
  end
end