问题
I've got a package which loops through a queue table. For each row to be done, it tries to download data. This is implemented using a Loop container. There are other executables outside the loop - logging, connecting to the remote service etc.
I'm having trouble with error handling. What I want to happen is:
- Any error within the loop container should update the queue table, to say "nope, couldn't download this one" (also some other error logging, but details not important). Then carry on to next item in loop (or onwards, if at end of loop);
- Any error outside the loop container should fail the package immediately, and also log an overall package failure;
- Any error within the loop container should NOT fail the package, nor log an overall package failure.
I've implemented this with two OnError event handlers: one for the loop container, with Propagate set to False; and one for the package. The package event handler should thus only fire for errors outside the loop container. Loop container's MaximumErrorCount is set to 0 (never fail because of errors).
When I introduce an artificial error into an ExecuteSQL task in the loop, this works perfectly. The loop container's handler fires, but not the package's.
But there's a Web Service task in the loop. When this encounters an error, SSIS handles it really oddly:
- First, the package OnError handler fires
- Then the loop container's handler fires
Is there something weird about the Web Service Task? Or is the error it throws:
An error occurred with the following error message: "Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException: The type of the value (Empty) being assigned to variable "User::WSResponse" differs from the current variable type (String).
of a different "flavour" or "severity" from the one thrown by the ExecuteSQL task:
Executing the query "SELECT CONVERT(int,'This is not convertible to int')" failed with the following error: "Conversion failed when converting the varchar value...
?
I tried to make the ExecSQL task's error more "severe" - a type mismatch. SELECT a varchar value, and in the SSIS ResultSet assign this value to an INT32 variable. The error handlers handled this error perfectly:
An error occurred while assigning a value to variable "AnIntVariable": "Input string was not in a correct format.".
Is it something about the WST error being a "...DTSRunTimeException" that makes it bypass error handling and go straight to the package level?
来源:https://stackoverflow.com/questions/63744552/ssis-error-handling-bypassed-by-web-service-task