OptrisSdkException
public class OptrisSdkException : Exception
The base of every error this SDK raises.
There is one error model in this package and it is exceptions. Catch OptrisSdkException to handle anything the SDK can go wrong with, or one of its derived types to handle a particular kind.
The exception to that rule is deliberate and narrow: where a failure is routine rather than exceptional -- reading a process interface that may simply be unplugged, or asking for a frame that has not arrived yet -- the API also offers a Try…(out T) method that returns false instead. That is the ordinary C# idiom for a poll loop, and it costs the caller nothing. Every such method says so on its own documentation.
Example Handle everything the same way:
try { using var camera = ThermalCamera.Open(); camera.Start(); } catch (OptrisSdkException error) { Console.Error.WriteLine($"camera unavailable: {error.Message}"); }
OptrisSdkException: constructors
public OptrisSdkException(string message)
Create an exception with a message and no native status.
message: What went wrong.
public OptrisSdkException(string message, int status)
Create an exception carrying the underlying native status.
message: What went wrong.status: The native status code, for a log or a support ticket.
public OptrisSdkException(string message, Exception innerException)
Create an exception wrapping another.
message: What went wrong.innerException: The underlying cause.
OptrisSdkException: properties
public int Status { get; }
The native status code behind this exception, or zero if it did not come from a native call.
Present for diagnostics, not for control flow: branch on the exception type, and quote this number in a support ticket. Its values are those of optris_sdk_status in optris/sdk_c.h.