Custom Task Error Handling - Displaying Custom Error Message

Custom Task Error Handling - Displaying Custom Error Message

Post by Philip Ta » Sat, 10 Nov 2001 13:14:38


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().

--- 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


   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

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


Philip Tan