Handle exceptions and logging messages
- Last UpdatedApr 08, 2026
- 2 minute read
This scenario guides you through the steps required to handle exceptions and logging messages.
The example Business Logic Tier (BLT) component will split the input string into tokens using the comma as a separator.
To identify the code associated with each step, see the code comments in the Example code section.
To retrieve parameters and return results
- Open the Program.cs file from the created project.
- Navigate to the Process method of the TestBLTProcessor class.
- Add a DNALogAdapter to the log messages.
- Load the local variables from the parameters.
- Load the results into an output parameter and the results dataset.
- Load the RowsAffected attribute.
The RowsAffected attribute value usually indicates the number of rows that have been modified by the BLT component, but it can also be used to count the number of rows returned by the BLT component.
- Check the TestBLT component execution using the DALBLTTestClient application.
For more information, see Check the execution of a BLT component using the DALBLTTestClient application.
Example code
// Add a DNALogAdapter to log messages.
private IDNALog Log { get; } = DNALogAdapter.Instance;
Parameters = new BLTParameterList
{
new BLTParameter(szName: "tokens", paramType: typeof(string), bOptional: false, bIsOutput: false)
};
public override void Process()
{
// Load the local variables from the parameters.
var tokens = (String)Parameters.Item(0).Value;
try
{
var arrayTokens = tokens.Split(',');
var token1 = arrayTokens[0];
var token2 = arrayTokens[1];
DataTable tabularResult = new DataTable("Result");
tabularResult.Columns.Add("tokens", typeof(String));
// Load the results into the output parameters and the results dataset.
DataRow row = tabularResult.NewRow();
row[0] = token1;
tabularResult.Rows.Add(row);
row = tabularResult.NewRow();
row[0] = token2;
tabularResult.Rows.Add(row);
RowsAffected = 2;
AddResultSet(tabularResult);
}
catch (Exception ex)
{
Log.Always(quot;TestBLT: {ex.Message}");
throw new BLTException(ex.Message);
}
}