comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Good Ada Style For Impossible Actions?
Date: Mon, 28 Oct 2002 17:13:41 GMT
Date: 2002-10-28T17:13:41+00:00	[thread overview]
Message-ID: <3DBD7066.1040205@acm.org> (raw)
In-Reply-To: 8w2v9.20054$T_.485432@iad-read.news.verio.net

Dr Nancy's Sweetie wrote:
> Jeffrey Carter wrote, in reply to a question about when to use exceptions
> and functions for testing error conditions:
> 
>>It sounds as if you could have mouse events outside the proper window
>>at any time, so such an event would not be exceptional. So having a
>>function would probably be a good idea.
>>
>>But if you use the function and still get a mouse event outside the
>>proper window, you should also have an exception to indicate that.
> 
> 
> If the function tries to compute a logical address for an invalid
> mouse position, a CONSTRAINT_ERROR will be raised because the logical
> position will be outside its valid range.
> 
> Is there a good heuristic for "raise your own exception" and "don't
> clutter up the exception namespace"?

The function returns Boolean: True if the mouse pointer is in the active 
window; False otherwise. So it should catch the exception and return False.

The other subprogram returns the mouse position within the active 
window, and should only be called if the function mentioned above 
returns True. But of course people will ignore that rule, and in any 
case it may be possible for the mouse pointer to move between the 2 
calls. If the mouse pointer is outside the active window when this 
subprogram is called, then it should raise a specific exception to 
indicate this. Constraint_Error is not very informative in this context.

-- 
Jeff Carter
"It's all right, Taggart. Just a man and a horse being hung out there."
Blazing Saddles




  reply	other threads:[~2002-10-28 17:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-26 15:59 Good Ada Style For Impossible Actions? Dr Nancy's Sweetie
2002-10-26 21:11 ` Jeffrey Carter
2002-10-28  3:52   ` Dr Nancy's Sweetie
2002-10-28 17:13     ` Jeffrey Carter [this message]
2002-10-28 17:33       ` tmoran
2002-10-29  1:35         ` Dr Nancy's Sweetie
2002-10-28 17:52       ` Warren W. Gay VE3WWG
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox