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
3 weeks 5 days ago
3 weeks 5 days ago
38 weeks 4 days ago
39 weeks 3 days ago
39 weeks 3 days ago
40 weeks 3 days ago
41 weeks 4 hours ago
41 weeks 5 hours ago
41 weeks 2 days ago
41 weeks 3 days ago