SSIS Script Task is throwing an exception, how to view the message?

17,696

Just trap the exception in a try..catch statement and use the FireError method in the catch block:

public void Main()
{
    ...
    try
    {
        ...
        Dts.TaskResult = (int)ScriptResults.Success;
    }
    catch (Exception ex)
    {
        Dts.Events.FireError(0, "ERROR", ex.Message, null, 0);
        Dts.TaskResult = (int)ScriptResults.Failure;
    }
}
Share:
17,696
Slight
Author by

Slight

Test about me

Updated on June 13, 2022

Comments

  • Slight
    Slight almost 2 years

    SSIS is showing some useless "Target of invocation has thrown an error" along with an equally useless stack trace that shows only the invocation call. Logging is enabled.

    Is there a way to view the actual exception message thrown by the package without attaching some debugger?