summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-05-31 00:23:55 -0300
committerAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-05-31 00:23:55 -0300
commit22f5c6b3bb5fe314e8b2926237e26a13568a0986 (patch)
tree64e587e4f48389f13fd11e53b194ce1d4076b048
parentb977d8237845983018e1bf810dcdb77341e74fd4 (diff)
downloadhighline-22f5c6b3bb5fe314e8b2926237e26a13568a0986.tar.gz
Add NotInRangeQuestionError. Simplify error handling using an specific error class.
-rwxr-xr-xlib/highline.rb11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/highline.rb b/lib/highline.rb
index 19c8b55..1fc7b0e 100755
--- a/lib/highline.rb
+++ b/lib/highline.rb
@@ -42,6 +42,10 @@ class HighLine
# do nothing, just creating a unique error type
end
+ class NotInRangeQuestionError < QuestionError
+ # do nothing, just creating a unique error type
+ end
+
# The setting used to disable color output.
@@use_color = true
@@ -547,10 +551,13 @@ class HighLine
end
end
else
- explain_error(:not_in_range, question)
- raise QuestionError
+ raise NotInRangeQuestionError
end
+ rescue NotInRangeQuestionError
+ explain_error(:not_in_range, question)
+ retry
+
rescue NotValidQuestionError
explain_error(:not_valid, question)
retry