diff options
author | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-05-31 00:23:55 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-05-31 00:23:55 -0300 |
commit | 22f5c6b3bb5fe314e8b2926237e26a13568a0986 (patch) | |
tree | 64e587e4f48389f13fd11e53b194ce1d4076b048 | |
parent | b977d8237845983018e1bf810dcdb77341e74fd4 (diff) | |
download | highline-22f5c6b3bb5fe314e8b2926237e26a13568a0986.tar.gz |
Add NotInRangeQuestionError. Simplify error handling using an specific error class.
-rwxr-xr-x | lib/highline.rb | 11 |
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 |