clear_err

Function clear_err 

Source
pub unsafe extern "C" fn clear_err(context: *mut c_context)
Expand description

@brief 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:

  1. A previous call failed, and the error was caught and handled.
  2. The context is reused with our error handling helper function.
  3. The callback passed to the helper function doesn’t actually make a call to a Nix function.
  4. The handled error is raised again, from an unrelated call.

This failure can be avoided by clearing the error message after handling it.