Software Development
Blogs and Discussion
developer.*
Books Articles Blogs Subscribe d.* Gear About Home

SSIS MaximumErrorCount and FireError in Script Tasks - Some Notes

Some things I learned while experimenting with exception handling in SSIS today:

The first lesson I learned is that calling FireError does not halt execution. The script code will continue executing past that point. This is different than the behavior of Throw, which short circuits further inline execution and forwards control to a handler (either a local Catch block, or up the stack if there is no internal handler).

Similarly, if you make a call to FireError in the code of a Script Task and that increments the number of errors to be equal to MaximumErrorCount, the script task will finish executing all the way to the end of Main() before deciding that the task should be failed because the MaximumErrorCount has been reached.

Attempts to force the task to have a status of Success will be ignored if MaximumErrorCount is reached.

Throwing an error does not increment the error count; only calling FireError does (or leaving the exception unhandled by not catching it).

A suppressed exception (caught in a Catch block and not re-thrown, or suppressed with On Error Resume Next in an SSIS Script Task will be ignored by SSIS. Only if it goes unhandled, or if FireError is called, with the error count increase. Similarly, the OnError event will only fire if an exception goes unhandled, or if FireError is called.

Try this example to see the execution continue past the FireError. It's also interesting to put a messagebox call in an OnError event handler and see the event handler fire (I think on a separate thread) during the execution of the script task.

Try
Throw New System.Exception("Forced error for testing.")
Catch e As System.Exception
System.Windows.Forms.MessageBox.Show("Before FireError")
Dts.Events.FireError(-1, "N/A", e.ToString(), "", 0)
System.Windows.Forms.MessageBox.Show("After FireError")
Dts.TaskResult = Dts.Results.Failure
End Try

Dts.TaskResult = Dts.Results.Success
System.Windows.Forms.MessageBox.Show("End of Main.")

Comments welcome.

Dan

Recent comments

User login

About our advertising.

Atom Feed

developer.* Blogs also has an Atom feed, located at this url.

Click here for more information about Atom.

A Jolt Award Finalist
Software Creativity 2.0
Foreword by Tom DeMarco

Recent Posters

Based on most recent 60 days, sorted by # of posts and name.

Google
Web developer.*

Who's online

There are currently 0 users and 24 guests online.

Syndicate

Syndicate content
All views expressed by authors, bloggers, and commentors are their own and do not necessarily reflect the views of developer.* or its proprietors.
Click to read the Copyright Notice.

All content copyright ©2000-2005 by the individual specified authors (and where not specified, copyright by Read Media, LLC). Reprint or redistribute only with written permission from the author and/or developer.*.

www.developerdotstar.com