SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Event Handlers. Onerror Vs OnFailure


Event Handlers. Onerror Vs OnFailure

Author
Message
dndaughtery
dndaughtery
SSC Eights!
SSC Eights! (864 reputation)SSC Eights! (864 reputation)SSC Eights! (864 reputation)SSC Eights! (864 reputation)SSC Eights! (864 reputation)SSC Eights! (864 reputation)SSC Eights! (864 reputation)SSC Eights! (864 reputation)

Group: General Forum Members
Points: 864 Visits: 1086
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?
jvolaire
jvolaire
SSC Rookie
SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)SSC Rookie (34 reputation)

Group: General Forum Members
Points: 34 Visits: 250
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

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search