Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Event Handlers. Onerror Vs OnFailure Expand / Collapse
Author
Message
Posted Thursday, July 17, 2014 12:50 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Monday, September 8, 2014 2:49 PM
Points: 331, Visits: 749
I want to add a sendMail task so that if a task fails or has an error an email is sent with the error description. I've noticed I can use the system::ErrorCode in the OnError event handler but can't use it in the OnFailure event handler. When I set the tasks ForceExecutionResult to Failure for testing and have the send mail task in the Onerror the task doesn't run. When I have the send mail task in the OnFailure it will but I get an error because I have the expression for the MessageSource using the System::ErrorCode in it. How can I set the task eventhandler so that when t has any error the send mail is run and can send the error description?
Post #1593795
Posted Friday, July 18, 2014 12:18 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, August 29, 2014 3:43 AM
Points: 14, Visits: 215
Hi There

From my understanding these event handlers serve different purposes:

a) OnError: This error handler handles errors that occur across the package and will be raised for each error that occurs.
b) OnTaskFailed: This error handler is raised when a specific task fails completely.

There are different ways to get this information back; but you could log errors to a table; consolidate and send a mail after that process for each task failure (so that you don't receive multiple emails) or you could receive the details for each error and then an informational notification of which task was affected. It all depends on what you're looking for.

This would be something I would work with for error information (fairly comprehensive) within a send mail task in the OnError event handler.

"This package task " + @[System::SourceName] + " ran at " + (DT_WSTR,50) @[System::StartTime] + ", and ended with the following error message for task: " + @[System::TaskName] + ". The error information is as follows: " + (DT_WSTR,50) @[System::ErrorCode] + " " + @[System::ErrorDescription]

Best way to see the purpose of each is to setup event handlers for both (with working variables i.e. as you have seen don't use @[System::ErrorCode] under the OnTaskFailed send mail task). Setup a task that will fail and look at the feedback you get via mail.

Hope this helps


MCITP Sql Server 2008: Business Intelligence. 4 Years +
Jason Vollaire
Post #1593914
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse