1
2
3
4
5
6
7
8
9
10
11
12#ifndef ERROR_H
13#define ERROR_H
14
15#include "qemu/compiler.h"
16#include "qapi-types.h"
17#include <stdbool.h>
18
19
20
21
22
23typedef struct Error Error;
24
25
26
27
28
29
30void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
31 GCC_FMT_ATTR(3, 4);
32
33
34
35
36
37
38void error_set_errno(Error **errp, int os_error, ErrorClass err_class,
39 const char *fmt, ...) GCC_FMT_ATTR(4, 5);
40
41#ifdef _WIN32
42
43
44
45
46
47void error_set_win32(Error **errp, int win32_err, ErrorClass err_class,
48 const char *fmt, ...) GCC_FMT_ATTR(4, 5);
49#endif
50
51
52
53
54#define error_setg(errp, fmt, ...) \
55 error_set(errp, ERROR_CLASS_GENERIC_ERROR, fmt, ## __VA_ARGS__)
56#define error_setg_errno(errp, os_error, fmt, ...) \
57 error_set_errno(errp, os_error, ERROR_CLASS_GENERIC_ERROR, \
58 fmt, ## __VA_ARGS__)
59#ifdef _WIN32
60#define error_setg_win32(errp, win32_err, fmt, ...) \
61 error_set_win32(errp, win32_err, ERROR_CLASS_GENERIC_ERROR, \
62 fmt, ## __VA_ARGS__)
63#endif
64
65
66
67
68void error_setg_file_open(Error **errp, int os_errno, const char *filename);
69
70
71
72
73ErrorClass error_get_class(const Error *err);
74
75
76
77
78Error *error_copy(const Error *err);
79
80
81
82
83const char *error_get_pretty(Error *err);
84
85
86
87
88
89
90void error_propagate(Error **dst_errp, Error *local_err);
91
92
93
94
95void error_free(Error *err);
96
97
98
99
100
101extern Error *error_abort;
102
103#endif
104