Reputation: 1582
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?
Upvotes: 7
Views: 25381
Reputation: 878
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;
}
}
Upvotes: 19