Your best friend for file transfer.

Fetch application logoFetch

Error numbers for AppleScript (6 posts)

This is an archived topic. The information in it is likely to be out-of-date and no longer applicable to current versions of Fetch.
  • Started 10 years ago by John Sandell
  • Latest reply 10 years ago from Jim Matthews
  • John Sandell Member

    I use Fetch 4.0.3 in an AppleScripted application. Files are uploaded via ISDN in response to emails received - typical file size is around 2MB - and I have 2 questions:

    Occasionally the upload fails for some reason - possibly the server drops the line or goes busy. Last time this happened I returned to find the script had moved on and tried to do the next thing, rather than flagging an error. Should I expect an error number? The (simplified) script is of the form:

    tell application "Fetch 4.0.3"
    try
    with timeout of 300 seconds
    put into url (this_URL) item (alias file_name)
    end timeout
    on error the error_message number error_number
    end try
    end tell

    My second question is: just after the upload starts, there is a long (1-2 minute) pause while Fetch and the server do nothing much, and then the upload proceeds at full speed. It always looks as if it's going to fail. Any explanation for this? And the buffer size looks as if it's a lot bigger in 4.0.3 than it was in 3.0.3, so the progress circle is only updated infrequently (so I can't tell if anything is happening).

    Thanks and regards
    John Sandell

    Posted 10 years ago #

  • Jim Matthews Administrator

    By putting the "put into" command inside a try/on error/end try block you're telling AppleScript to ignore any errors from the "put into" command. You could remove the "try", "on error..." and "end try" lines to have AppleScript stop when an error happens.

    I'm surprised that it would take a minute for the first buffer (128KB) to be sent, but that may be what you are seeing. Once the first buffer has been sent the progress indicator should be updated more frequently.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 10 years ago #

  • John Sandell Member

    > telling AppleScript to ignore any errors from the "put into" command.

    Ahah, I didn't know that. Can I use "tell", "with timeout...", "put into", "end timeout", "on error...", "end tell"? The script normally runs unattended and it needs to pick up any error number and do something positive if there's a problem.

    Regarding the 'start up delay', I have just tried some big manual file uploads to two different sites, using both 4.0.3 under OSX and 3.0.3 under 9.1 - and all of them start immediately! Is there any reason that scripted "put into" might operate differerently than uploads under manual control?

    I note that 3.0.3 updates the progress circle every 32KB rather than 128KB in 4.0.3, so the feedback feels smoother in the old version.

    Thanks and regards
    John Sandell

    Posted 10 years ago #

  • Jim Matthews Administrator

    If you take out the try statement you have to also take out the "on error" and "end try" lines. The idea is that when you have code like this:

    try
    [some statements]
    on error the error_message number error_number
    [error-handling statements]
    end try

    any error that happens in the statements between "try" and "on error" will result in AppleScript executing the statements between "on error" and "end try". So if you want to do something about an error, you have to do it there. Your script currently does nothing with the error, so it's as if it didn't happen.

    I can't think of why running from a script would cause a delay at the beginning of the transfer.

    Fetch 4.0.3 does use a larger buffer than 3.0.3, and there's currently no way to change it. We'll try to improve that in the future.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 10 years ago #

  • John Sandell Member

    I simplified my script too far for posting here :-) What it actually does is:

    on error the error_message number error_number
    if the error_number is -128 then
    set e to "Upload aborted by user"
    my do_error_msge(e, false)
    else
    set e to ("Upload failed, error " & error_number)
    my do_error_msge(e, false)
    end if
    end try

    In the situation I first mentioned, where it looked as if the line had dropped, I was left with half a file on the server and the Fetch window open, but the script had moved on (in fact the script logged that the upload had succeeded, which is what it does if no error is reported).

    Thanks and regards
    John

    Posted 10 years ago #

  • Jim Matthews Administrator

    If Fetch had an error your do_error_msge function should have been called with an error number. I'd make sure that do_error_msge logs error it sees, so that you can see what was reported after the fact.

    Thanks,

    Jim Matthews
    Fetch Softworks

    Posted 10 years ago #

Topic closed

This topic has been closed.