Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 527
Slight Avatar asked Jul 15 '15 16:07

Slight


People also ask

How do I capture an error message in SSIS?

Adding OnError Event Handler to SSIS Package If you click on the Event Handlers tab in the package, you will see a drop down for the different Event Handlers as shown below. I am going to select OnError for the Package and add an Execute SQL Task to the Event Handlers section as shown below.

What is the difference between Script task and Script component in SSIS?

The Script task is configured on the Control Flow tab of the designer and runs outside the data flow of the package. The Script component is configured on the Data Flow page of the designer and represents a source, transformation, or destination in the Data Flow task.


1 Answers

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;
    }
}
like image 139
lucazav Avatar answered Nov 03 '22 15:11

lucazav