File: error.rb

package info (click to toggle)
ruby-slop 4.10.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 204 kB
  • sloc: ruby: 1,163; makefile: 6
file content (53 lines) | stat: -rw-r--r-- 1,338 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module Slop
  # Base error class.
  class Error < StandardError
  end

  # Raised when calling `call` on Slop::Option (this
  # method must be overriden in subclasses)
  class NotImplementedError < Error
  end

  # Raised when an option that expects an argument is
  # executed without one. Suppress with the `suppress_errors`
  # config option.
  class MissingArgument < Error
    attr_reader :flags

    # Get all the flags that matches
    # the option with the missing argument
    def initialize(msg, flags)
      super(msg)
      @flags = flags
    end
  end

  # Raised when an unknown option is parsed or when trying to fetch an
  # unexisting option via `Slop::Result#fetch`.
  # Suppress with the `suppress_errors` config option.
  class UnknownOption < Error
    attr_reader :flag

    def initialize(msg, flag)
      super(msg)
      @flag = flag
    end
  end

  # Raised when a required option is *not* parsed.
  # Suppress with the `suppress_errors` config option.
  class MissingRequiredOption < Error
  end

  # Raised when a given option is provided by the user and does not
  # match the expected format for that type. This is only raised if
  # validate_types is set to true.
  class InvalidOptionValue < Error
    attr_reader :flag

    def initialize(msg, flag)
      super(msg)
      @flag = flag
    end
  end
end