Custom Task Error Handling

Custom Task Error Handling

Post by Mishelle Grane » Thu, 08 Nov 2001 06:14:17



I am trying to write a custom task in VB6 for DTS (SQL Server 2000).  

Everything works great, except when I try to raise a user-defined error.  Even this is not a problem when I run the package from dtsrun, but when I run the package from DTS Designer, this is what happens:  I get my user-defined error as expected, then I get another message saying 'Unexpected error occurred.  An error result was returned without an error message.'  Then the application hangs.

My first thought is that it tries to look up the text associated with my user-defined error, and there isn't any.  But why is it trying to do that, when I've already given it the text, and it has correctly displayed the text?  So I tried giving it a real error number, instead of a user-defined one.  It displays my error message correctly, then gives 'This function is not supported on this system.'  Then it hangs.

Can anyone help with this?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

Custom Task Error Handling

Post by Mishelle Grane » Thu, 08 Nov 2001 06:51:33


Additional information:  The problem happens as described when the package is set to fail on first error.  If that option is not checked, I get the following "Package Execution Results" box that says "1 task failed during execution", at which point it hangs.

My code looks something like this:

Private Sub CustomTask_Execute(parameters)
    On Error Goto errHandler
    ...
        Err.Raise VBObjectError + 1000, , "My error msg"
    ...
    pTaskResult = DTSTaskExecResult_Success
    Exit Sub
errHandler:
    pTaskResult = DTSTaskExecResult_Failure
    Err.Raise Err.Number, Err.Source, Err.Description
End Sub


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

Custom Task Error Handling

Post by Darren Gree » Thu, 08 Nov 2001 07:01:45




Quote:

>I am trying to write a custom task in VB6 for DTS (SQL Server 2000).

>Everything works great, except when I try to raise a user-defined error.  Even
>this is not a problem when I run the package from dtsrun, but when I run the
>package from DTS Designer, this is what happens:  I get my user-defined error as
>expected, then I get another message saying 'Unexpected error occurred.  An
>error result was returned without an error message.'  Then the application
>hangs.

>My first thought is that it tries to look up the text associated with my user-
>defined error, and there isn't any.  But why is it trying to do that, when I've
>already given it the text, and it has correctly displayed the text?  So I tried
>giving it a real error number, instead of a user-defined one.  It displays my
>error message correctly, then gives 'This function is not supported on this
>system.'  Then it hangs.

>Can anyone help with this?

I assume you wish to raise an error in the CustomTask_Execute method.

I have successfully used both methods below-

Err.Raise vbObjectError + lErr, sErrSrc, sErrDesc

pPackageEvents.OnError m_sName & " (" & m_sDescription & ")
CustomTask_Execute", lErr, sErrSrc, sErrDesc, "", 0, "", True

--
Darren Green (SQL Server MVP)
http://www.sqldts.com

(Which version of SQL Server? What is the full error message?)

 
 
 

Custom Task Error Handling

Post by Trey Johnso » Thu, 08 Nov 2001 12:21:49


Just to add....

Make sure your custom task is executing on the Main Thread.

--
Trey Johnson
-----------------------------
Data Warehouse Architect
Encore Development
www.encoredev.com
-----------------------------
PASS Director of Program Development
www.sqlpass.org
-----------------------------

Don't miss the PASS North America conference - 6 Pre-Conference
Seminars, 70 + SQL Server Sessions.......January 28-31, 2002 Denver





> >I am trying to write a custom task in VB6 for DTS (SQL Server 2000).

> >Everything works great, except when I try to raise a user-defined error.
Even
> >this is not a problem when I run the package from dtsrun, but when I run
the
> >package from DTS Designer, this is what happens:  I get my user-defined
error as
> >expected, then I get another message saying 'Unexpected error occurred.
An
> >error result was returned without an error message.'  Then the
application
> >hangs.

> >My first thought is that it tries to look up the text associated with my
user-
> >defined error, and there isn't any.  But why is it trying to do that,
when I've
> >already given it the text, and it has correctly displayed the text?  So I
tried
> >giving it a real error number, instead of a user-defined one.  It
displays my
> >error message correctly, then gives 'This function is not supported on
this
> >system.'  Then it hangs.

> >Can anyone help with this?

> I assume you wish to raise an error in the CustomTask_Execute method.

> I have successfully used both methods below-

> Err.Raise vbObjectError + lErr, sErrSrc, sErrDesc

> pPackageEvents.OnError m_sName & " (" & m_sDescription & ")
> CustomTask_Execute", lErr, sErrSrc, sErrDesc, "", 0, "", True

> --
> Darren Green (SQL Server MVP)
> http://www.sqldts.com

> (Which version of SQL Server? What is the full error message?)

 
 
 

Custom Task Error Handling

Post by Mishelle Grane » Wed, 14 Nov 2001 10:08:34


Thanks.  After more debugging, I've found the problem to be the Decision Support Objects - maybe I'm not using them correctly.  My code looks like this:

Private Sub CustomTask_Execute(parameters)
    On Error Goto errHandler

    Set dsoServer = New DSO.Server
(1) dsoServer.Connect "myServer"
    ...
        Err.Raise VBObjectError + 1000, , "My error msg"
    ...
    pTaskResult = DTSTaskExecResult_Success
    Exit Sub
errHandler:
(2) dsoServer.CloseServer
    pTaskResult = DTSTaskExecResult_Failure
    Err.Raise Err.Number, Err.Source, Err.Description
End Sub

*If I don't connect to the server, (remove (1) and (2) ) the error is raised successfully (but my task doesn't work)
*If I put (2) right after (1), also no problem
*If I have (1) and not (2), the app hangs
*If I have (1) and (2), it doesn't hang, but I get 'Access Is Denied - Invalid procedure call or argument'.  It seems like the call to CloseServer causes a new error, so my original error information is lost.

Oviously I need to connect to the server, but there must be something else I need to do to disconnect in order for my error to be propagated correctly.

Can anyone help?

Mishelle Graney
Clarity Systems

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

 
 
 

1. Custom Task Error Handling - Displaying Custom Error Message

Hi,

I'm currently working on creating a custom task in VB6.
When it comes to error handling, the recommended error
handling procedure in MSDN is to bubble up the error to
the package event sink using oPackageEvent.onError().
Hence:

--- Sample Code Starts ---

Private Sub CustomTask_Execute(ByVal pPackage As Object,
ByVal pPackageEvents As Object, ByVal pPackageLog As
Object, pTaskResult As DTS.DTSTaskExecResult)
   On Error GoTo errHandler

   ' Business logic
   openConnection(param, param)

   pTaskResult = DTSTaskExecResult_Success
   Exit Sub

errHandler:

   pTaskResult = DTSTaskExecResult_Failure
   if Err.Number=xxxx Then closeConnection

   ' Bubble errors to the package eventsink
   If Not pPackageEvents Is Nothing Then
      pPackageEvents.OnError "CustomTask_Execute method
failed", Err.Number, Err.Source, Err.Description, "",
0, "", True
   End If

   Exit Sub
End Sub

--- Sample Code Ends ---

However, I notice that when error is raised, the specific
error message (Err.Description) will not be displayed on
the DTS Designer execution status dialog box. The only
message I'll get would be "The task reported failure on
execution".

I'm not sure if I have done it correctly. Anyone knows how
to get the custom error messages displayed?

Thanks!

Philip Tan

2. ASA for Linux download

3. Custom Task Error Handling

4. JUST GO TO HTTP://WWW.GROOVE311.HOMEPAGE.COM TO GET FREE MONEY 100 STAMPS FOR FREE AND A CHECK $50 MONTHLY FOR FREE YOU HAVE NOTHING TO LOSE.

5. DTS Custom task in C# and threading model of DTS C# custom tasks

6. Trouble removing Login ID's in SQL65

7. Error Assigning Task object to Custom Task object while calling DTS APIs in VB.NET

8. INFORMIX and Novell

9. Error handling and custom error messages

10. Using a Dynamic Properties Task to set a Custom Task in DTS

11. Calling a DTS standard task/custom task from a T-SQL Stored procedure

12. DTS Custom Task 'Not Implemented' error

13. Custom task :Query Interface Error in Vb.Net