Exceptions Instead of Return Values

Valid from List & Label 8
Error codes are standardly managed in List & Label via return values. But, L&L's .NET component uses exceptions. - in true .NET style.

Due to these changes, you can use the comfortable .NET error management you're accustomed to - you no longer need to explicitly evaluate each single return value. This also enables the respective calls to be simplified.

Example in C#

The following source code shows the use of List & Label exceptions when calling the Designer. If something fails, the user will be informed via a message box.

// Button "Designer"
protected void button1_Click (object sender, System.EventArgs e)
{
    try
    {
        // Init Data Reader
        InitDataReader();

        // Start Designer
        LL.Design(0, this.Handle, "Sample", LlProject.Label | LlProject.FileAlsoNew, "simple.lbl", true);
    }
    catch (Exception LlException)
    {
        // Catch Exceptions
        MessageBox.Show("Information: " + LlException.Message + "\n\nThis information was generated by a List & Label custom exception.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
}

Example in VB.NET

The same example in VB.NET:

'Button "Designer"
Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click

Try
    'Init Data Reader
    InitDataReader()
    
    'Start Designer
    LL.Design(0, Me.Handle, "Sample", LlProject.Label Or LlProject.FileAlsoNew, "simple.lbl", True)

Catch LlException As Exception

    'Catch Exceptions
    MessageBox.Show("Information: " + LlException.Message + "\n\nThis information was generated by a List & Label custom exception.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information)

End Try

End Sub

Individual Evaluation of Exceptions

Being that various exceptions may be raised, you can decide via try..catch[..finally]-block, for which errors a reaction should occur. In the following example, a user abort is completely ignored, for example, whereas other exceptions are shown.

try
{
    // Implementation
}
catch (LL_User_Aborted_Exception e)
{
    // Ignore user abort
}
catch (Exception e)
{
    // Catch Exceptions
    MessageBox.Show("Information: " + LlException.Message + "\n\nThis information was generated by a List & Label custom exception.",     "Information", MessageBoxButtons.OK,     MessageBoxIcon.Information);
}


IDKBTE000528 KBTE000528