Search code examples
c#.netsql-servervb.netssis

What are acceptable values for the parameter "errorCode" of Dts.Events.FireError in SSIS..?


SSIS has the scripting objects Script Task and Script Component, which provide the intended .Net programming environment. Therein are various event methods for triggering error conditions & sending information to the outer environment. Microsoft docs here.

Among these methods are three which correspond to those typical for one of the Microsoft "Basic" languages. They are: FireInformation, FireWarning, and FireError.

For each of these, the first parameter is a code number: informationCode, warningCode, and errorCode, respectively.

For these codes, I ask the following:

  • What are acceptable values? (I cannot find this information)
  • Are there any system-reserved ranges? (such as 0 to 1023 and/or 1024 to 65535 in VBA)
  • Are there any constants? (such as VBA.vbObjectError = &H80040000)
  • Are there any Enums for the codes?

For anyone who does much work in SSIS, one may already know some of the documentation is a bit thin, so any information would be helpful.

So basically...what's the scoop?


Solution

  • This code can be any value that fits into Int32. The suggestion is that you use it like an error level. The sample code uses 3 for info, 14 for warning and 18 for error.

    /* This script task can fire events for logging purposes.
     * 
     * Example of firing an error event:
     *  Dts.Events.FireError(18, "Process Values", "Bad value", "", 0);
     * 
     * Example of firing an information event:
     *  Dts.Events.FireInformation(3, "Process Values", "Processing has started", "", 0, ref fireAgain)
     * 
     * Example of firing a warning event:
     *  Dts.Events.FireWarning(14, "Process Values", "No values received for input", "", 0);
     * */
    

    You might decide to use a range that distinguishes errors from severe errors. All other examples that I've seen always use 0, though this would depend on your use case.

    For integration purposes, any error is enough to stop the bus to prevent incomplete data loads -- whether this is a data anomaly or system availability issue. For this type of work, I have never bothered with a code range because all errors are equally bad.