lib/highline/custom_errors.rb in highline-2.0.0.pre.develop.2 vs lib/highline/custom_errors.rb in highline-2.0.0.pre.develop.4

- old
+ new

@@ -1,19 +1,56 @@ class HighLine + + # Internal HighLine errors. module CustomErrors - # Internal HighLine errors. - class QuestionError < StandardError + # 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 - class NotValidQuestionError < QuestionError + # Bare Question error + class QuestionError < ExplainableError + # (see ExplainableError#explanation_key) + def explanation_key + nil + end end - class NotInRangeQuestionError < QuestionError + # Invalid Question error + class NotValidQuestionError < ExplainableError + # (see ExplainableError#explanation_key) + def explanation_key + :not_valid + end end - class NoConfirmationQuestionError < QuestionError + # Out of Range Question error + class NotInRangeQuestionError < ExplainableError + # (see ExplainableError#explanation_key) + def explanation_key + :not_in_range + end end - class NoAutoCompleteMatch < StandardError + # 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