Expand description
§Error handling in LabVIEW Interop
There are four error paths that the labview-interop crate needs to handle:
-
MgError and MgErrorCode, Internal: LabView Memory Manager –> Rust This crate calls the labview memory manager internally to deal with memory owned by LabVIEW. The functions of the memory manager return MgErr. The documentation on https://www.ni.com/docs/en-US/bundle/labview/page/labview-manager-function-errors.html gives a full list of possible error values.
-
MgErrorCode: to LabVIEW through function return We want to be able to return the errors generated internally through the function return and be understood on the LabVIEW side. This is straight forward for Errors of MgError type. But we will have an internal compound Error type that can have a different type. When using status returns, these can only be converted to a very generic error code. Therefore 3
-
InteropError: to LabVIEW through ErrorCluster parameter Our internal
LvInteropError
compound error can easily be converted to an ErrorCluster. For MgErrors the conversion is straight forward. The correct source descriptions are gotten from the memory manager throughNIGetOneErrorCode
. For non LV errors, a generic error is leveraged, and the source description is overwritten. -
from LabVIEW through ErrorCluster parameter Will labview-interop ever need to make sense of an error? It may be good enough to differentiate between an error and warnings. TBD
§Notes on Error Handling in LabVIEW
This section is a summary of defined and observed LabVIEW behaviour
§Labview error clusters and data types
THe labview error clusters possess an error code of i32. The error lists on labviewwiki show official Labview errors as low as 0x8000000A and as high as 0x3FFC0105.
§the Labview Memory Manager / MgErr and types
The memory manager code examples from the documentation call the return value of the c function calls ´MgErr´ of type i32
§Custom error ranges
Custom defined errors can range from
- -8999 through -8000
- 5000 through 9999
- 500,000 through 599,999
For obvious reasons the labview interop crate will use the range 542,000 to 542,999 for errors that are generated internally and not handed down by c functions
§Error Implementation
There is a hierarchy of Status and Errors
- A status encode Success and Error
The errors we expect to receive from calls to labview functions are MgErrorCode MgError
Our generic Error handling is an enum LabviewInteropError This enum has custom errors for our internal use, we can hold MgErrors, and as last resort we can also hold LVError
Enums§
- Internal
Error - Examples
- LVInterop
Error - MgError
- MgError is the subset of LabVIEW errors that may occur when dealing with the memory manager So in the context of Rust-LabVIEW-interop these are the kind of labview errors we may trigger within the library