Re: trapping type conversion errors [message #22296] |
Thu, 02 November 2000 10:52 |
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  |
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  |
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
------------------------------------------------------------ --------------
|
|
|