Hi,
I'm building a custom task and just wondering what is the correct way of passing errors back to SSIS. Is there a rcommended approach to doing this. Currently I just wrap everything in a TRY...CATCH and use componentEvents to fire it back! Here's my code:
public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser,IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
{
 bool failed = false;
 try
 {
 /*
 * do stuff in here
 */
 }
 catch (Exception e)
 {
 componentEvents.FireError(-1, "", e.Message, "", 0);
 failed = true;
 }
 if (failed)
 {
 return DTSExecResult.Failure;
 }
 else
 {
 return DTSExecResult.Success;
 }
}
Any comments?
-Jamie
Anyone?|||the boolean flag isn't necessary. the line: return DTSExecResult.Failure;
could be in the catch block.|||
Good point. cheers Duane!! So it should be:
public override DTSExecResult Execute(Connections connections, VariableDispenser variableDispenser,IDTSComponentEvents componentEvents, IDTSLogging log, object transaction)
{
 try
 {
 /*
 * do stuff in here
 */
 return DTSExecResult.Success;
 }
 catch (Exception e)
 {
 componentEvents.FireError(-1, "", e.Message, "", 0);
 return DTSExecResult.Failure;
 }
}
-Jamie
[Microsoft follow-up]
|||
Hi Jamie,
this looks like the correct approach to me.
sql 
No comments:
Post a Comment