pub unsafe extern "C" fn nix_clear_err(context: *mut nix_c_context)
Expand description
Clear the error message from a nix context. This is performed implicitly by all functions that accept a context, so this won’t be necessary in most cases. However, if you want to clear the error message without calling another function, you can use this. Example use case: a higher order function that helps with error handling, to make it more robust in the following scenario:
- A previous call failed, and the error was caught and handled.
- The context is reused with our error handling helper function.
- The callback passed to the helper function doesn’t actually make a call to a Nix function.
- The handled error is raised again, from an unrelated call. This failure can be avoided by clearing the error message after handling it.