Error Handling

  • How do you trap errors in an ActiveX Script task?  I try "On Error Resume Next", but it doesn't seem to resume with the next line of code, it seems to resume with the next DTS Step/Task.

    Am I missing something?

     

  • The 'On Error Resume Next' statement basically causes the error to be ignored.

    Without that statement the script will abort on the line that causes the error. This is undesirable as you don't get the opportunity to handle the error.

    My suggestion would be to use the following structure to trap errors,

    On Error Resume Next
    <your code statement>
    <local err variable> = Err.Number
    <local err desc> = Err.Description
    On Error Goto 0
    <interrogate local err variable for error condition>

    Important to note that to provide more granular error trapping, reduce the number of statements after the 'On Error Resume Next' and enclose code in IF ... THEN ... ELSE ... END IF blocks.

    --------------------
    Colt 45 - the original point and click interface

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

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