summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-05-31 00:29:52 -0300
committerAbinoam Praxedes Marques Jr <abinoam@gmail.com>2015-05-31 00:29:52 -0300
commitde934b4ee1109277a8c5e7b97d59c14ac4240c44 (patch)
treed7f28dda2af594f1cbb0e8059729ce3afd084bef
parent22f5c6b3bb5fe314e8b2926237e26a13568a0986 (diff)
downloadhighline-de934b4ee1109277a8c5e7b97d59c14ac4240c44.tar.gz
Add NoConfirmationQuestionError. Simplify error handling using an specific error class.
-rwxr-xr-xlib/highline.rb13
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