]> Git Repo - qemu.git/blob - error.h
ehci: switch to nanoseconds
[qemu.git] / error.h
1 /*
2  * QEMU Error Objects
3  *
4  * Copyright IBM, Corp. 2011
5  *
6  * Authors:
7  *  Anthony Liguori   <[email protected]>
8  *
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.
11  */
12 #ifndef ERROR_H
13 #define ERROR_H
14
15 #include <stdbool.h>
16
17 /**
18  * A class representing internal errors within QEMU.  An error has a string
19  * typename and optionally a set of named string parameters.
20  */
21 typedef struct Error Error;
22
23 /**
24  * Set an indirect pointer to an error given a printf-style format parameter.
25  * Currently, qerror.h defines these error formats.  This function is not
26  * meant to be used outside of QEMU.
27  */
28 void error_set(Error **err, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
29
30 /**
31  * Returns true if an indirect pointer to an error is pointing to a valid
32  * error object.
33  */
34 bool error_is_set(Error **err);
35
36 /**
37  * Get a human readable representation of an error object.
38  */
39 const char *error_get_pretty(Error *err);
40
41 /**
42  * Get an individual named error field.
43  */
44 const char *error_get_field(Error *err, const char *field);
45
46 /**
47  * Get an individual named error field.
48  */
49 void error_set_field(Error *err, const char *field, const char *value);
50
51 /**
52  * Propagate an error to an indirect pointer to an error.  This function will
53  * always transfer ownership of the error reference and handles the case where
54  * dst_err is NULL correctly.
55  */
56 void error_propagate(Error **dst_err, Error *local_err);
57
58 /**
59  * Free an error object.
60  */
61 void error_free(Error *err);
62
63 /**
64  * Determine if an error is of a speific type (based on the qerror format).
65  * Non-QEMU users should get the `class' field to identify the error type.
66  */
67 bool error_is_type(Error *err, const char *fmt);
68
69 #endif
This page took 0.025974 seconds and 4 git commands to generate.