SdkException Class

Definition

Namespace: P1.CameraSdk

A simple subclass of the System.Exception class for SDK caused exceptions. Wraps an SDK CameraSdk.ErrorCode for resolving the corresponding error. More…

public class SdkException :  Exception

Remarks

A simple subclass of the System.Exception class for SDK caused exceptions. Wraps an SDK CameraSdk.ErrorCode for resolving the corresponding error.

To catch any SDK related errors, you can try catch on this class. If you need to distinguish between different kind of SDK errors, you can filter on the ErrorCode property.

Here we use the when clause to filter specific SDK errors:

try
{
    var camera = Camera.OpenUsbCamera();
}
catch(SdkException e) when (e.mErrorCode == kErrorCameraNotFound)
{
    Console.WriteLine($"Camera not opened, error: {e}");
}

Here the string interpolation ($"... error: {e}") uses the ToString to print the SDK’s error description.

See also:

CameraSdk.ErrorCode

Constructors

SdkException(ErrorCode errorCode)

Create an SDK error from an ErrorCode, with an automatically loaded description

Properties

ErrorCode

The error code provided by the underlying SDK

ErrorMessage

Optional error description from the SDK

Methods

ToString()

A string representation of the SDK exception