]> git.proxmox.com Git - mirror_qemu.git/blame - error.h
Rename target_phys_addr_t to hwaddr
[mirror_qemu.git] / error.h
CommitLineData
d5ec4f27
LC
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
d3608b7c 15#include "compiler.h"
13f59ae8 16#include "qapi-types.h"
d5ec4f27
LC
17#include <stdbool.h>
18
19/**
df1e608a
LC
20 * A class representing internal errors within QEMU. An error has a ErrorClass
21 * code and a human message.
d5ec4f27
LC
22 */
23typedef struct Error Error;
24
25/**
df1e608a
LC
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
28 * of QEMU.
d5ec4f27 29 */
13f59ae8 30void error_set(Error **err, ErrorClass err_class, const char *fmt, ...) GCC_FMT_ATTR(3, 4);
d5ec4f27 31
75d789f8
LC
32/**
33 * Same as error_set(), but sets a generic error
34 */
35#define error_setg(err, fmt, ...) \
36 error_set(err, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__)
37
d5ec4f27
LC
38/**
39 * Returns true if an indirect pointer to an error is pointing to a valid
40 * error object.
41 */
42bool error_is_set(Error **err);
43
ea25fbca
LC
44/*
45 * Get the error class of an error object.
46 */
47ErrorClass error_get_class(const Error *err);
48
79020cfc
LC
49/**
50 * Returns an exact copy of the error passed as an argument.
51 */
52Error *error_copy(const Error *err);
53
d5ec4f27
LC
54/**
55 * Get a human readable representation of an error object.
56 */
57const char *error_get_pretty(Error *err);
58
d5ec4f27
LC
59/**
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
d195325b 62 * dst_err is NULL correctly. Errors after the first are discarded.
d5ec4f27
LC
63 */
64void error_propagate(Error **dst_err, Error *local_err);
65
66/**
67 * Free an error object.
68 */
69void error_free(Error *err);
70
d5ec4f27 71#endif