OptrisOptrisDocumentation

Documentation/OTC SDK/OTC SDK — C++ API referencev12.0

optris::sdk::pif::PifException

A PIF operation was refused, and code() says which refusal it was.

Every fallible call on PifController throws this rather than returning a value-or-error, because a Result is not part of any external API surface. See the warning at the top of optris/sdk/error.h, and the reason the two mechanisms cannot coexist on one surface is below.

Why code() and not a type per refusal: Why code() and not a type per refusal The recording surface took the other route: seven RecordError enumerators became seven exception types. PifError's nine enumerators are not seven unrelated conditions, they are nine answers from one device about one request, and an application handling them branches rather than catching; "out of range" and "not connected" want the same catch site and different sentences. So the code travels on the exception and the type stays one.

It is also what keeps the C ABI's answers unchanged across this conversion: capi::StatusOf(PifError) is still the single written-out declaration of what each code is owed, and the C boundary now reads it off code() instead of off a returned Result. Every optris_sdk_pif_* status is the one it was before.

A subclass of SdkException and of nothing narrower, so a catch ([SdkException](/documentation/sdks/otc-sdk/v12.0/api/classes/optris.sdk.sdkexception) &) written before this type existed keeps catching every PIF refusal.

Inherits from optris::sdk::SdkException.

Public functions

PifException

PifException(std::string message, PifError code)

Parameters

Name Description
message What went wrong, naming the specifics. The enum says what kind of answer it is; this says what happened.
code Which refusal it was.

code

auto code() const -> PifError

Which refusal it was. Never PifError::kOk, because an operation that succeeded does not throw.