Updated: October 28, 2024 |
Store a new error code as a variable if the new error is not zero and the previously stored one is
#include <qh/error.h>
int qh_sticky_error(int *sticky_error, int new_error)
This function allows a caller to make successive calls with a sticky_error variable and a new, potentially different error. After the caller makes successive calls to the this function, it can look at the value of sticky_error to determine what the first error was, if any.
In addition to standard error numbers (e.g., errno), this function can be used with any set of error codes that consider zero to indicate success (e.g., many enumerated types).
The value of new_error.