comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Error Handling Advice
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Error Handling Advice [message #82730 is a reply to message #82723] Fri, 11 January 2013 16:15 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matthew Argall writes:

>
>> 3. The only exception to 2 is for utility functions
>
> What qualifies as a utility function?
>
>
>> 5. I make sure I check EVERY SINGLE ONE of my parameters and keywords to
>> see that they are defined as *something*.
>
> Just to see if they are defined, or do you make sure they are scalars, arrays, have the proper dimensions, etc? Is there a "too overboard"?

Well, despite all my blather, there is a "too overboard" factor at work,
too. If it matters to me, I'll do more checking. But, if I write a
program that works with images, I probably won't check to see if the
user passed in a scalar value. Not worth my time to do so. Let CATCH
handle it. But, I can tell I do a LOT more checking than most of the IDL
programs I look at. :-)

>> 9. CATCH error handlers are to catch program errors that I know
>> inevitably occur, but that I don't anticipate. I check EVERY SINGLE ONE of my
>> parameters and I try to anticipate common errors and check for those.
>> Sometimes it is embarrassing how much code is error handling code in a
>> small program. Don't use CATCH error handlers because you are too lazy
>> to do any work.
>
> So, check all anticipated/potential errors, then include a CATCH for the ones you miss. When you discover one you missed, you put in another check. Is that the gist of it?

Yes, I often add more error checking if I find people are confused about
how something should be used. But, I also look at the interface. If I
call a program wrong several times in a row, I know I got the interface
wrong, and I try to change it. One example off the top of my head is
PS_START. It has a default filename of "idl.ps", so if the user wants to
change it, they can use a FILENAME keyword:

PS_START, FILENAME='test.ps'

But, when I use PS_START, I always called it like this:

PS_START, 'test.ps'

I did that so often, I made an optional positional parameter to
handle this correctly. FILENAME was what I can an "inefficient" keyword.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Using function after .reset
Next Topic: Transparent and Overplotted Images with cgImage

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 20:51:39 PDT 2025

Total time taken to generate the page: 0.55590 seconds