File: custom_errors.rb

package info (click to toggle)
ruby-highline 3.1.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 800 kB
  • sloc: ruby: 5,789; sh: 7; makefile: 4
file content (57 lines) | stat: -rw-r--r-- 1,401 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# encoding: utf-8

class HighLine
  # Internal HighLine errors.
  module CustomErrors
    # An error that responds to :explanation_key
    class ExplainableError < StandardError
      # Explanation key as Symbol or nil. Used to
      # select the proper error message to be displayed.
      # @return [nil, Symbol] explanation key to get the
      #   proper error message.
      def explanation_key
        nil
      end
    end

    # Bare Question error
    class QuestionError < ExplainableError
      # (see ExplainableError#explanation_key)
      def explanation_key
        nil
      end
    end

    # Invalid Question error
    class NotValidQuestionError < ExplainableError
      # (see ExplainableError#explanation_key)
      def explanation_key
        :not_valid
      end
    end

    # Out of Range Question error
    class NotInRangeQuestionError < ExplainableError
      # (see ExplainableError#explanation_key)
      def explanation_key
        :not_in_range
      end
    end

    # Unconfirmed Question error
    class NoConfirmationQuestionError < ExplainableError
      # (see ExplainableError#explanation_key)
      def explanation_key
        nil
      end
    end

    # Unavailable auto complete error
    class NoAutoCompleteMatch < ExplainableError
      # (see ExplainableError#explanation_key)
      def explanation_key
        :no_completion
      end
    end
  end
end