Subject: Re: [sup-devel] [PATCH] buffer: throw "friendly" exception if question is too long

From: Rich Lane <[email-masked]>
Date: Tue, 18 Jan 2011 22:41:06 -0500

Applied to master.
_______________________________________________
Sup-devel mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-devel

---

From: Sascha Silbe <[email-masked]>
Date: Tue, 18 Jan 2011 19:26:37 +0100

If a question is too long to fit on screen, the buffer manager currently
throws a hard-to-understand exception deep down in the buffer logic.
Explicitly checking for this condition and throwing a descriptive exception
makes life easier for hook authors.

Signed-off-by: Sascha Silbe <[email-masked]>
---
 lib/sup/buffer.rb |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
index d1fef5a..25ea132 100644
--- a/lib/sup/buffer.rb
+++ b/lib/sup/buffer.rb
@@ -575,6 +575,7 @@ EOS
   ## screen
   def ask domain, question, default=nil, &block
     raise "impossible!" if @asking
+    raise "Question too long" if Ncurses.cols <= question.length
     @asking = true
 
     @textfields[domain] ||= TextField.new
-- 
1.7.2.3