summaryrefslogtreecommitdiff
path: root/lib/highline
diff options
context:
space:
mode:
authorAbinoam P. Marques Jr <abinoam@gmail.com>2017-11-04 23:24:32 -0300
committerAbinoam P. Marques Jr <abinoam@gmail.com>2017-11-05 11:26:00 -0300
commit81d9ee76bd326069142a36dc8216594e47659963 (patch)
treed1bca6601cfef62a94ccdc9a4bd38bb59c8225f8 /lib/highline
parentb799c5858c99bad7ae8d3c3070acf036848be0ba (diff)
downloadhighline-81d9ee76bd326069142a36dc8216594e47659963.tar.gz
Implement proc or string for error
Diffstat (limited to 'lib/highline')
-rw-r--r--lib/highline/question_asker.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/highline/question_asker.rb b/lib/highline/question_asker.rb
index cb8dfa8..52f4959 100644
--- a/lib/highline/question_asker.rb
+++ b/lib/highline/question_asker.rb
@@ -115,10 +115,15 @@ class HighLine
## Delegate to Highline
def explain_error(error)
- @highline.say(question.final_responses[error]) if error
+ @highline.say(error_final_response(error)) if error
@highline.say(question.ask_on_error_msg)
end
+ def error_final_response(error)
+ final_response = question.final_responses[error]
+ final_response.call(question.answer) rescue final_response
+ end
+
def gather_with_array
[].tap do |answers|
answers << ask_once