checkPhidgetError function
void
checkPhidgetError(
- int res,
- String operation
)
Implementation
void checkPhidgetError(int res, String operation) {
if (res != PhidgetErrorCode.EPHIDGET_OK) {
final errorStrPtr = calloc<Pointer<Utf8>>();
try {
phidgetGetErrorDescriptionFunction(res, errorStrPtr);
final errorMessage = (errorStrPtr.value == nullptr)
? "Unknown Phidget Error (could not get description)"
: errorStrPtr.value.toDartString();
throw Exception('Phidget Error during $operation: "$errorMessage" (Code: ${PhidgetErrorCode(res).value})');
} finally {
calloc.free(errorStrPtr);
}
}
}