root / error.h @ a0595d9e
History | View | Annotate | Download (1.8 kB)
1 |
/*
|
---|---|
2 |
* QEMU Error Objects
|
3 |
*
|
4 |
* Copyright IBM, Corp. 2011
|
5 |
*
|
6 |
* Authors:
|
7 |
* Anthony Liguori <aliguori@us.ibm.com>
|
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 "compiler.h" |
16 |
#include <stdbool.h> |
17 |
|
18 |
/**
|
19 |
* A class representing internal errors within QEMU. An error has a string
|
20 |
* typename and optionally a set of named string parameters.
|
21 |
*/
|
22 |
typedef struct Error Error; |
23 |
|
24 |
/**
|
25 |
* Set an indirect pointer to an error given a printf-style format parameter.
|
26 |
* Currently, qerror.h defines these error formats. This function is not
|
27 |
* meant to be used outside of QEMU.
|
28 |
*/
|
29 |
void error_set(Error **err, const char *fmt, ...) GCC_FMT_ATTR(2, 3); |
30 |
|
31 |
/**
|
32 |
* Returns true if an indirect pointer to an error is pointing to a valid
|
33 |
* error object.
|
34 |
*/
|
35 |
bool error_is_set(Error **err);
|
36 |
|
37 |
/**
|
38 |
* Returns an exact copy of the error passed as an argument.
|
39 |
*/
|
40 |
Error *error_copy(const Error *err);
|
41 |
|
42 |
/**
|
43 |
* Get a human readable representation of an error object.
|
44 |
*/
|
45 |
const char *error_get_pretty(Error *err); |
46 |
|
47 |
/**
|
48 |
* Get an individual named error field.
|
49 |
*/
|
50 |
const char *error_get_field(Error *err, const char *field); |
51 |
|
52 |
/**
|
53 |
* Get an individual named error field.
|
54 |
*/
|
55 |
void error_set_field(Error *err, const char *field, const char *value); |
56 |
|
57 |
/**
|
58 |
* Propagate an error to an indirect pointer to an error. This function will
|
59 |
* always transfer ownership of the error reference and handles the case where
|
60 |
* dst_err is NULL correctly.
|
61 |
*/
|
62 |
void error_propagate(Error **dst_err, Error *local_err);
|
63 |
|
64 |
/**
|
65 |
* Free an error object.
|
66 |
*/
|
67 |
void error_free(Error *err);
|
68 |
|
69 |
/**
|
70 |
* Determine if an error is of a speific type (based on the qerror format).
|
71 |
* Non-QEMU users should get the `class' field to identify the error type.
|
72 |
*/
|
73 |
bool error_is_type(Error *err, const char *fmt); |
74 |
|
75 |
#endif
|