diff options
author | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-05-31 00:29:52 -0300 |
---|---|---|
committer | Abinoam Praxedes Marques Jr <abinoam@gmail.com> | 2015-05-31 00:29:52 -0300 |
commit | de934b4ee1109277a8c5e7b97d59c14ac4240c44 (patch) | |
tree | d7f28dda2af594f1cbb0e8059729ce3afd084bef | |
parent | 22f5c6b3bb5fe314e8b2926237e26a13568a0986 (diff) | |
download | highline-de934b4ee1109277a8c5e7b97d59c14ac4240c44.tar.gz |
Add NoConfirmationQuestionError. Simplify error handling using an specific error class.
-rwxr-xr-x | lib/highline.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/highline.rb b/lib/highline.rb index 1fc7b0e..e6fd95a 100755 --- a/lib/highline.rb +++ b/lib/highline.rb @@ -46,6 +46,10 @@ class HighLine # do nothing, just creating a unique error type end + class NoConfirmationQuestionError < QuestionError + # do nothing, just creating a unique error type + end + # The setting used to disable color output. @@use_color = true @@ -545,15 +549,16 @@ class HighLine template_renderer = TemplateRenderer.new(template, question, self) confirm_question = template_renderer.render end - unless context_change.agree(confirm_question) - explain_error(nil, question) - raise QuestionError - end + raise NoConfirmationQuestionError unless context_change.agree(confirm_question) end else raise NotInRangeQuestionError end + rescue NoConfirmationQuestionError + explain_error(nil, question) + retry + rescue NotInRangeQuestionError explain_error(:not_in_range, question) retry |