Information.IsError(Object) Method

Definition

Returns a Boolean value indicating whether an expression is an exception type.

public static bool IsError (object? Expression);
public static bool IsError (object Expression);

Parameters

Expression
Object

Required. Object expression.

Returns

Returns a Boolean value indicating whether an expression is an exception type.

Examples

The following example uses the IsError function to check if an expression represents a system exception.

Sub demonstrateIsError(ByVal firstArg As Integer)
    Dim returnVal As New Object
    Dim badArg As String = "Bad argument value"
    Dim errorCheck As Boolean
    If firstArg > 10000 Then
        returnVal = New System.ArgumentOutOfRangeException(badArg)
    End If
    errorCheck = IsError(returnVal)
End Sub

Remarks

IsError returns True if the expression represents an Object variable that derives from the Exception class in the System namespace.

An exception that derives from System.Exception can be caught with the Try...Catch...Finally statements.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also