7

I have a Script component (Script Transformation), which I need to be able to fail the DFT, i.e. the Data Flow Task that it is part of.

I am firing an error like this

try
{
   // Does some work here, which can fail...
}
catch (Exception ex)
{
   bool pbCancel = false;
   this.ComponentMetaData.FireError(0, Variables.TaskName, "Error message: " + ex.Message, String.Empty, 0, out pbCancel);
}

However, FireError does not cause the task to fail.

Note that this is a script component inside a data transformation task - not a script task.

What do I do to fail this task from the script component?

codeMonkey
  • 4,134
  • 2
  • 31
  • 50
Anders
  • 894
  • 2
  • 10
  • 25

2 Answers2

2

In your example you are catching the exception but not throwing it. Just add

catch (Exception ex)
{
    // ... your other code here
    throw ex;
}

and the component will fail.

codeMonkey
  • 4,134
  • 2
  • 31
  • 50
1

This should be what you're looking for - 2008 R2 C# script component.

bool fireAgain = true;
IDTSComponentMetaData100 myMetaData;
myMetaData = this.ComponentMetaData;

//for information
myMetaData.FireInformation(0, "SubComponent", "Description", string.Empty, 0, ref fireAgain);
//for error
myMetaData.FireError(0, "SubComponent", ex.Message.ToString() + ex.StackTrace, string.Empty, 0, out fireAgain);
esre
  • 87
  • 9