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

Home » Public Forums » archive » Re: trapping type conversion errors
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: trapping type conversion errors [message #22296] Thu, 02 November 2000 10:52
Vapuser is currently offline  Vapuser
Messages: 63
Registered: November 1998
Member
Craig Markwardt <craigmnet@cow.physics.wisc.edu> writes:

> Vapuser <vapuser@catspaw.jpl.nasa.gov> writes:
>
>> I may be missing something, but are type conversion errors
>> untrappable?
>
> Apparently you trap these with ON_IOERROR. I just verified this with
> your example.

Thanks.

I decided to just check the !error_state structure. I guess I see
the sense in making these be IO errors, but sometimes I wonder if a
more *comprehensive* error trapping strategy would be better.

> I think some other folks on the list know some caveats
> about this; it may not always be foolproof.
>

If anyone knows of any exceptions, could you let me know?

whd
--
William Daffer: 818-354-0161: William.Daffer@jpl.nasa.gov
Re: trapping type conversion errors [message #22310 is a reply to message #22296] Wed, 01 November 2000 14:59 Go to previous message
George Constantinides is currently offline  George Constantinides
Messages: 16
Registered: July 2000
Junior Member
William,

The error generated in your example is an IO error and can be trapped with
ON_IOERROR. It is a bit of a pain that CATCH will not catch this type of
error, but all is not lost.


PRO junk
; catch,error
; IF error NE 0 THEN BEGIN
; message,!error_state.msg,/info
; return
; ENDIF

ON_IOERROR, bad_data

t = ['01','aa']
tt = fix(t,type=2)
;print,"I'm here"
;message,!error_state.msg,/info

; help,!error_state,/st

Return

bad_data:
help,!error_state,/st

END


Regards,

George Constantinides
email: GeorgeC@mhl.nsw.gov.au
URL: http://www.mhl.nsw.gov.au
Re: trapping type conversion errors [message #22311 is a reply to message #22310] Wed, 01 November 2000 14:45 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Vapuser <vapuser@catspaw.jpl.nasa.gov> writes:

> I may be missing something, but are type conversion errors
> untrappable?

Apparently you trap these with ON_IOERROR. I just verified this with
your example. I think some other folks on the list know some caveats
about this; it may not always be foolproof.

As for math errors, yes I believe the only way to detect them is with
CHECK_MATH().

Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Old Timers ??
Next Topic: IDLWAVE 4.5

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

Current Time: Wed Oct 08 15:39:19 PDT 2025

Total time taken to generate the page: 0.00631 seconds