]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * QError header file. | |
3 | * | |
4 | * Copyright (C) 2009 Red Hat Inc. | |
5 | * | |
6 | * Authors: | |
7 | * Luiz Capitulino <lcapitulino@redhat.com> | |
8 | * | |
9 | * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. | |
10 | * See the COPYING.LIB file in the top-level directory. | |
11 | */ | |
12 | #ifndef QERROR_H | |
13 | #define QERROR_H | |
14 | ||
15 | #include "qdict.h" | |
16 | #include <stdarg.h> | |
17 | ||
18 | typedef struct QErrorStringTable { | |
19 | const char *desc; | |
20 | const char *error_fmt; | |
21 | } QErrorStringTable; | |
22 | ||
23 | typedef struct QError { | |
24 | QObject_HEAD; | |
25 | QDict *error; | |
26 | int linenr; | |
27 | const char *file; | |
28 | const char *func; | |
29 | const QErrorStringTable *entry; | |
30 | } QError; | |
31 | ||
32 | QError *qerror_new(void); | |
33 | QError *qerror_from_info(const char *file, int linenr, const char *func, | |
34 | const char *fmt, va_list *va); | |
35 | void qerror_print(const QError *qerror); | |
36 | QError *qobject_to_qerror(const QObject *obj); | |
37 | ||
38 | /* | |
39 | * QError class list | |
40 | */ | |
41 | #define QERR_COMMAND_NOT_FOUND \ | |
42 | "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }" | |
43 | ||
44 | #define QERR_DEVICE_ENCRYPTED \ | |
45 | "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s } }" | |
46 | ||
47 | #define QERR_DEVICE_LOCKED \ | |
48 | "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }" | |
49 | ||
50 | #define QERR_DEVICE_NOT_ACTIVE \ | |
51 | "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }" | |
52 | ||
53 | #define QERR_DEVICE_NOT_FOUND \ | |
54 | "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }" | |
55 | ||
56 | #define QERR_DEVICE_NOT_REMOVABLE \ | |
57 | "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }" | |
58 | ||
59 | #define QERR_INVALID_PARAMETER_TYPE \ | |
60 | "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }" | |
61 | ||
62 | #define QERR_INVALID_PASSWORD \ | |
63 | "{ 'class': 'InvalidPassword', 'data': {} }" | |
64 | ||
65 | #define QERR_JSON_PARSING \ | |
66 | "{ 'class': 'JSONParsing', 'data': {} }" | |
67 | ||
68 | #define QERR_KVM_MISSING_CAP \ | |
69 | "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }" | |
70 | ||
71 | #define QERR_MISSING_PARAMETER \ | |
72 | "{ 'class': 'MissingParameter', 'data': { 'name': %s } }" | |
73 | ||
74 | #define QERR_QMP_BAD_INPUT_OBJECT \ | |
75 | "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }" | |
76 | ||
77 | #define QERR_UNDEFINED_ERROR \ | |
78 | "{ 'class': 'UndefinedError', 'data': {} }" | |
79 | ||
80 | #endif /* QERROR_H */ |