Adding more robust error messages to a custom task

Adding more robust error messages to a custom task

Post by Rob Vieir » Fri, 27 Apr 2001 14:09:24



I'm building a custom FTP task to do a PUT in SQL Server 7.0 (the example
code I've seen out there is truly just simple examples and is always focused
around a GET). I can detect in the task a wide variety of errors, but the
only option I seem to have in terms of passing something back to the calling
package is a DTSTaskExecResult_Failure - this makes it hard for me to judge
what went wrong. I'd like to pass out something of an errors collection - at
least a collection of messages or a single message that is more
representative of the error than "task reported failure".

Is there a specific method call or property set I can refer to in order to
deal with custom error messages in a custom DTS task? I don't see anything
in the object model.

Thanks,

Rob

 
 
 

Adding more robust error messages to a custom task

Post by Gert E.R. Draper » Fri, 27 Apr 2001 16:00:14


Using Package Events

Event OnError(EventSource As String, ErrorCode As Long, Source As String,
Description As String, HelpFile As String, HelpContext As Long,
IDofInterfaceWithError As String, pbCancel As Boolean)
    Member of DTS.Package2
    Indicates an Error and provides information about the error. Set
'Cancel' to TRUE to stop execution.

-GertD


Quote:> I'm building a custom FTP task to do a PUT in SQL Server 7.0 (the example
> code I've seen out there is truly just simple examples and is always
focused
> around a GET). I can detect in the task a wide variety of errors, but the
> only option I seem to have in terms of passing something back to the
calling
> package is a DTSTaskExecResult_Failure - this makes it hard for me to
judge
> what went wrong. I'd like to pass out something of an errors collection -
at
> least a collection of messages or a single message that is more
> representative of the error than "task reported failure".

> Is there a specific method call or property set I can refer to in order to
> deal with custom error messages in a custom DTS task? I don't see anything
> in the object model.

> Thanks,

> Rob


 
 
 

Adding more robust error messages to a custom task

Post by Darren Gree » Sat, 28 Apr 2001 06:32:09



It.ProfessionalSQL.com> writes

Quote:>I'm building a custom FTP task to do a PUT in SQL Server 7.0 (the example
>code I've seen out there is truly just simple examples and is always focused
>around a GET). I can detect in the task a wide variety of errors, but the
>only option I seem to have in terms of passing something back to the calling
>package is a DTSTaskExecResult_Failure - this makes it hard for me to judge
>what went wrong. I'd like to pass out something of an errors collection - at
>least a collection of messages or a single message that is more
>representative of the error than "task reported failure".

>Is there a specific method call or property set I can refer to in order to
>deal with custom error messages in a custom DTS task? I don't see anything
>in the object model.

>Thanks,

>Rob

You can use the pPackageEvents Object  to raise OnError-

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

I found some strange behaviour when using pTaskResult =
DTSTaskExecResult_Failure, but can't remember what now. Just looking at
one of my half finished tasks where I really started looking at raising
errors in a nice way to give as much info as possible, I've actually got
it commented out.

I seem to recall if I didn't it suppressed my message. The workflow in
the rest of the package worked as excepted though.

You could also just use Err.Raise with or without
DTSTaskExecResult_Failure. I couldn't decide which worked best,
Err.Raise or OnError, or at least can't remember if I did!

Regards
--
Darren Green
SQL/DTS - http://www.swynk.com/friends/green/

 
 
 

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. INSERT INTO and "" values ???

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

4. Progress DBA Contract - Atlanta

5. How to add custom DTS error messages?

6. URGENT HELP: multi-window SHOW GETS

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

8. HELP HyperScript/Wingz

9. Custom error message in custom Web publishing

10. How to replace SQL Errors with custom Error messages

11. Error handling and custom error messages

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

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