Nix 2.17.0
Nix, the purely functional package manager; stable external interfaces
|
Dealing with errors from the Nix side. More...
Data Structures | |
struct | nix_c_context |
This object stores error state. More... | |
Macros | |
#define | NIX_OK 0 |
No error occurred. More... | |
#define | NIX_ERR_UNKNOWN -1 |
An unknown error occurred. More... | |
#define | NIX_ERR_OVERFLOW -2 |
An overflow error occurred. More... | |
#define | NIX_ERR_KEY -3 |
A key error occurred. More... | |
#define | NIX_ERR_NIX_ERROR -4 |
A generic Nix error occurred. More... | |
Typedefs | |
typedef int | nix_err |
Type for error codes in the NIX system. More... | |
typedef struct nix_c_context | nix_c_context |
Functions | |
nix_c_context * | nix_c_context_create () |
Allocate a new nix_c_context. More... | |
void | nix_c_context_free (nix_c_context *context) |
Free a nix_c_context. Does not fail. More... | |
const char * | nix_err_msg (nix_c_context *context, const nix_c_context *ctx, unsigned int *n) |
Retrieves the most recent error message from a context. More... | |
nix_err | nix_err_info_msg (nix_c_context *context, const nix_c_context *read_context, char *value, int n) |
Retrieves the error message from errorInfo in a context. More... | |
nix_err | nix_err_name (nix_c_context *context, const nix_c_context *read_context, char *value, int n) |
Retrieves the error name from a context. More... | |
nix_err | nix_err_code (const nix_c_context *read_context) |
Retrieves the most recent error code from a nix_c_context. More... | |
Dealing with errors from the Nix side.
To handle errors that can be returned from the Nix API, a nix_c_context can be passed to any function that potentially returns an error.
Error information will be stored in this context, and can be retrieved using nix_err_code and nix_err_msg.
Passing NULL instead will cause the API to throw C++ errors.
Example:
#define NIX_ERR_KEY -3 |
A key error occurred.
This error code is returned when a key error occurred during the function execution.
#define NIX_ERR_NIX_ERROR -4 |
A generic Nix error occurred.
This error code is returned when a generic Nix error occurred during the function execution.
#define NIX_ERR_OVERFLOW -2 |
An overflow error occurred.
This error code is returned when an overflow error occurred during the function execution.
#define NIX_ERR_UNKNOWN -1 |
An unknown error occurred.
This error code is returned when an unknown error occurred during the function execution.
#define NIX_OK 0 |
No error occurred.
This error code is returned when no error has occurred during the function execution.
typedef int nix_err |
Type for error codes in the NIX system.
This type can have one of several predefined constants:
nix_c_context * nix_c_context_create | ( | ) |
Allocate a new nix_c_context.
std::bad_alloc |
nix_c_context_free
. void nix_c_context_free | ( | nix_c_context * | context | ) |
Free a nix_c_context. Does not fail.
[out] | context | The context to free, mandatory. |
nix_err nix_err_code | ( | const nix_c_context * | read_context | ) |
Retrieves the most recent error code from a nix_c_context.
Equivalent to reading the first field of the context.
Does not fail
[in] | read_context | the context to retrieve the error message from |
nix_err nix_err_info_msg | ( | nix_c_context * | context, |
const nix_c_context * | read_context, | ||
char * | value, | ||
int | n | ||
) |
Retrieves the error message from errorInfo in a context.
Used to inspect nix Error messages.
[out] | context | optional, the context to store errors in if this function fails |
[in] | read_context | the context to retrieve the error message from |
[out] | value | The allocated area to write the error string to. |
[in] | n | Maximum size of the returned string. |
const char * nix_err_msg | ( | nix_c_context * | context, |
const nix_c_context * | ctx, | ||
unsigned int * | n | ||
) |
Retrieves the most recent error message from a context.
[out] | context | optional, the context to store errors in if this function fails |
[in] | ctx | the context to retrieve the error message from |
[out] | n | optional: a pointer to an unsigned int that is set to the length of the error. |
nix_err nix_err_name | ( | nix_c_context * | context, |
const nix_c_context * | read_context, | ||
char * | value, | ||
int | n | ||
) |
Retrieves the error name from a context.
Used to inspect nix Error messages.
context | optional, the context to store errors in if this function fails | |
[in] | read_context | the context to retrieve the error message from |
[out] | value | The allocated area to write the error string to. |
[in] | n | Maximum size of the returned string. |