Hi @Nick Ryan,
Please try the following step-by-step article to achieve what you need.
Capturing SQL Server Integration Services Package Errors Using OnError Event Handlers
The main point is that you don't need to assign values and/or pass around System::ErrorCode
and System::ErrorDescription
variables. They will be automatically available in the OnError Event handler.
UPDATE
Within a catch
block, a throw
statement with no expression can be used to re-throw the exception that was caught by the catch
block. Please see below.
catch (Exception ex)
{
// Failure
Dts.Variables["User::errorCode"].Value = 199;
Dts.Variables["User::errorMessage"].Value = ex.Message;
throw; // re-throw
result = (int)ScriptResults.Failure;
Dts.TaskResult = (int)ScriptResults.Failure;
}