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 #82702 is a reply to message #82701] Mon, 14 January 2013 13:02 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> I would probably write this particular set of routines like this.
>
> function add, a, b, SUCCESS=success
> Catch, theError
> IF theError NE 0 THEN BEGIN
> Catch, /CANCEL
> void = Error_Message()
> success = 0
> RETURN, !Null
> ENDIF
>
> success = 1
> result = a + b
> RETURN, result
> end
>
> pro call_add
> Catch, theError
> IF theError NE 0 THEN BEGIN
> Catch, /CANCEL
> void = Error_Message()
> RETURN
> ENDIF
>
> sum = add(a, b, SUCCESS=success)
> IF ~success THEN RETURN
>
> IF sum EQ !Null THEN message, 'Sum not valid'
> END

Or, even simpler:

function add, a, b
Catch, theError
IF theError NE 0 THEN BEGIN
Catch, /CANCEL
void = Error_Message()
RETURN, !Null
ENDIF

RETURN, a + b
end

pro call_add
Catch, theError
IF theError NE 0 THEN BEGIN
Catch, /CANCEL
void = Error_Message()
RETURN
ENDIF

sum = add(a, b)

IF sum EQ !Null THEN RETURN
END

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: Sat Oct 11 16:00:08 PDT 2025

Total time taken to generate the page: 0.08310 seconds