Enum ErrorMode

Enum Documentation

enum class navtk::ErrorMode

Defines whether error checking of inputs should be performed, and if so, how severe a response is desired when an error occurs.

For research & development purposes, as well as scientific code, ErrorMode::DIE is strongly recommended to catch problems early rather than having to work backwards from nonsensical outputs. ErrorMode::LOG can be useful for finding bugs in operational/embedded code. ErrorMode::OFF should be used in production embedded systems to avoid error-checking overhead.

The default global error mode is ErrorMode::OFF if navtk is compiled with -DNO_MATRIX_VAL. Otherwise, the default is ErrorMode::DIE. This can be changed at runtime using navtk::set_global_error_mode or by holding a navtk::ErrorModeLock. Many navtk functions will read the global error mode to decide whether to validate their inputs.

If you’re extending navtk and wish to incorporate optional error checking, consider taking an ErrorMode as an optional parameter that defaults to the value of navtk::get_global_error_mode, to allow your users the option of avoiding the global error mode.

navtk::utils::ValidationContext may be useful for checking bounds and conditions of matrices. If you perform custom validation, make sure any expensive calculations involved only happen if the error mode is not OFF, consider using navtk::log_or_throw to report your error messages.

Values:

enumerator OFF

Skip as much error-checking as possible for maximum performance.

enumerator LOG

Perform error checks and log warnings, but do not throw exceptions.

enumerator DIE

Throw exceptions when data are malformed.