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 string
21 * typename and optionally a set of named string parameters.
23 typedef struct Error Error
;
26 * Set an indirect pointer to an error given a printf-style format parameter.
27 * Currently, qerror.h defines these error formats. This function is not
28 * meant to be used outside of QEMU.
30 void error_set(Error
**err
, ErrorClass err_class
, const char *fmt
, ...) GCC_FMT_ATTR(3, 4);
33 * Returns true if an indirect pointer to an error is pointing to a valid
36 bool error_is_set(Error
**err
);
39 * Returns an exact copy of the error passed as an argument.
41 Error
*error_copy(const Error
*err
);
44 * Get a human readable representation of an error object.
46 const char *error_get_pretty(Error
*err
);
49 * Get an individual named error field.
51 const char *error_get_field(Error
*err
, const char *field
);
54 * Get an individual named error field.
56 void error_set_field(Error
*err
, const char *field
, const char *value
);
59 * Propagate an error to an indirect pointer to an error. This function will
60 * always transfer ownership of the error reference and handles the case where
61 * dst_err is NULL correctly. Errors after the first are discarded.
63 void error_propagate(Error
**dst_err
, Error
*local_err
);
66 * Free an error object.
68 void error_free(Error
*err
);
71 * Determine if an error is of a speific type (based on the qerror format).
72 * Non-QEMU users should get the `class' field to identify the error type.
74 bool error_is_type(Error
*err
, ErrorClass err_class
, const char *fmt
);