Custom Errors in VBscript ActiveX

  • Hi I have a DTS package one step of which is an Active X vb script to ftp a file to a site using an active X control.  I wish to trap some error text returned into an object on the FTP object and raise this error somehow, either by being able to raise the error to be seen outside the step or raising an entry in the event log

    The place where I want to be able to report the error is in bold

     

    '**********************************************************************

    '  Visual Basic ActiveX Script

    '************************************************************************

    OPTION EXPLICIT

    Function Main()

    Dim oFTP

    Dim oSmart

    Dim strresult

    Dim lresult

    Dim lconnection

    Dim errnumber

    ON ERROR RESUME NEXT

    set oFTP = CreateObject("ggukFTP.ggFTPServer")

    errnumber = err.number

    ON ERROR GOTO 0

    If errnumber <> 0 THEN

    set oFTP = Nothing

    Err.Raise ErrNumber

    Main = DTSTaskExecResult_fAILURE

    exit function

    End If

    ON ERROR RESUME NEXT

    lconnection = oFTP.FTPConnect("data.keywords.co.ukS", "keywords", "keywords")

    errnumber = err.number

    ON ERROR GOTO 0

    If errnumber <> 0 THEN

    set oFTP = Nothing

    Err.Raise ErrNumber

    Main = DTSTaskExecResult_fAILURE

    exit function

    End If

    If lconnection = True then

    ON ERROR RESUME NEXT

    lresult = oFTP.SendFiles("ftextract.zip","E:\Extracts\ftextract","ggukcards.zip",,False,True)

    errnumber = err.number 

    ON ERROR GOTO 0

    If errnumber <> 0 THEN

    set oFTP = Nothing

    Err.Raise ErrNumber

    Main = DTSTaskExecResult_fAILURE

    exit function

    End If

    strerrresult = oFTP.objFTPErrorDetails.ErrorDesc

    oFTP.disconnect

    Else

    strerrresult = "Could not connect to server"

    end if

    If strerrresult <> "" then

    'Raise some sort of error here

    set oFTP = Nothing

    Main = DTSTaskExecResult_fAILURE

    Else

    set oFTP = Nothing 

    Main = DTSTaskExecResult_Success

    End If

    End Function

  • This was removed by the editor as SPAM

  • I am assuming that you want to do some processing in a different step to handle the error?

    Can you define 2 Global Variables in the package; One Boolean gv_boolFTP, and One String gv_strMessage.  Your next step.. be it in the Workflow script or in the Task itself could test the value of gv_boolFTP to determine if the FTP was successful (=True) or not (=False)... If False, process the message in the GV String gv_strMessage.

    Not sure if that answers your question... If not please supply a little more information on how you want to process a failure of the FTP component.

    -Mike Gercevich

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply