Reputation: 643
I have created a class Library in VB.NET which we are calling from SSIS script task.
Could someone please advice how I can throw error back from VB.NET function which was suppose to return a string value but it returns null
, in that case I would like the SSIS script task to fail.
Upvotes: 0
Views: 222
Reputation: 1323
You can use the following code to fail the package if any exception / Null thrown from your function library. Replace YourMethodCall() to your method.
// For General exceptions
try
{
// Your Method call
var x = YourMethodCall();
if (string.IsNullOrEmpty(x))
{
Dts.Events.FireError(0, "Your component Name", "Your Error Message", string.Empty, 0);
}
else
{
bool isFireAgain = false;
Dts.Events.FireInformation(0, "You component Name", "Your Information for Successful run", string.Empty, 0, ref isFireAgain);
}
}
catch (Exception ex)
{
Dts.Events.FireError(0, "Your component Name", String.Format("Failed and Exception is : [{0}]",ex.Message), string.Empty, 0);
}
Hope this helps!
Upvotes: 1