4 * Copyright IBM, Corp. 2011
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU LGPL, version 2. See
10 * the COPYING.LIB file in the top-level directory.
16 #include "qapi-types.h"
20 * A class representing internal errors within QEMU. An error has a ErrorClass
21 * code and a human message.
23 typedef struct Error Error
;
26 * Set an indirect pointer to an error given a ErrorClass value and a
27 * printf-style human message. This function is not meant to be used outside
30 void error_set(Error
**err
, ErrorClass err_class
, const char *fmt
, ...) GCC_FMT_ATTR(3, 4);
33 * Same as error_set(), but sets a generic error
35 #define error_setg(err, fmt, ...) \
36 error_set(err, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__)
39 * Returns true if an indirect pointer to an error is pointing to a valid
42 bool error_is_set(Error
**err
);
45 * Get the error class of an error object.
47 ErrorClass
error_get_class(const Error
*err
);
50 * Returns an exact copy of the error passed as an argument.
52 Error
*error_copy(const Error
*err
);
55 * Get a human readable representation of an error object.
57 const char *error_get_pretty(Error
*err
);
60 * Propagate an error to an indirect pointer to an error. This function will
61 * always transfer ownership of the error reference and handles the case where
62 * dst_err is NULL correctly. Errors after the first are discarded.
64 void error_propagate(Error
**dst_err
, Error
*local_err
);
67 * Free an error object.
69 void error_free(Error
*err
);