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

Home » Public Forums » archive » CATCH error problem
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
CATCH error problem [message #66001] Wed, 08 April 2009 07:56
lbusett@yahoo.it is currently offline  lbusett@yahoo.it
Messages: 30
Registered: February 2006
Member
Hi all,

I'm writing a program to download satellite images from an ftp
site using the IDLnetUrl "GET" method. I'd like to be able to check
any ftp errors in file transfer and, if an error occurs, I'd like to
be able to tell to the program to wait some time, re-establish the
connection and try again to download the file for a fixed number of
times (e.g., 5 times). If data transfer failes for more than this
number of times, I want to abort the program.

The code that I'm using at the time is the following:

count_retry = 0 ; Initialize the counter
CATCH, theError

IF theError NE 0 THEN BEGIN
CATCH, /CANCEL
count_retry = count_retry +1 ; Error Occurred:
Increase the counter

IF (count_retry LE 5) THEN BEGIN ; If counter < 5 wait some
time, then go to "retry"
; and
try to download again
OBJ_DESTROY, oURL
some_time = 3
WAIT, some_time
GOTO, retry

ENDIF ELSE BEGIN ; If failed more than 5 times, exit

OBJ_DESTROY, oURL
ok = ERROR_MESSAGE(/Traceback,/Quiet)
RETURN,['FileGetErr',theError]

ENDELSE
ENDIF

retry:
; Define URL of the target FTP file
targetUrl = 'orders/'+ftp_dir+'/'+file_name

; Initialize IDLnetUrl Object
oUrl = OBJ_NEW('IDLnetUrl', URL_SCHEME='ftp', $
FTP_CONNECTION_MODE = 0, $ ; Passive connection
URL_HOST= ftp_url, $
URL_USERNAME=ftp_uname, $
URL_PASSWORD=ftp_pwd, $
URL_PATH=targetUrl, $
CALLBACK_FUNCTION ='MPM_PP_GETFILE_CALLBACK',/verbose $
)
out_name = out_dir+file_name
out_file = oURL->GET(FILENAME=out_name)
OBJ_DESTROY, oURL
RETURN, out_file

The first time that an error in data transfer occurs, the "catch"
procedure kicks in correctly, the counter is incremented and another
attempt is made. However, if another data transfer error occurs the
CATCH procedure does not kick in any more, and the program exits with
an error.

Does anyone know why is it happening ? Is there a "smarter" way to do
the job ?

Thanks in advance for the help,

Lorenzo
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: correlation between images
Next Topic: indexing

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

Current Time: Wed Oct 08 13:56:17 PDT 2025

Total time taken to generate the page: 0.00452 seconds