Luiz Capitulino | 9f9daf9 | 2009-11-18 23:05:30 -0200 | [diff] [blame] | 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" |
Markus Armbruster | 77e595e | 2009-12-07 21:37:16 +0100 | [diff] [blame] | 16 | #include "qstring.h" |
Markus Armbruster | 827b081 | 2010-02-18 19:46:49 +0100 | [diff] [blame] | 17 | #include "qemu-error.h" |
Luiz Capitulino | 9f9daf9 | 2009-11-18 23:05:30 -0200 | [diff] [blame] | 18 | #include <stdarg.h> |
| 19 | |
| 20 | typedef struct QErrorStringTable { |
| 21 | const char *desc; |
| 22 | const char *error_fmt; |
| 23 | } QErrorStringTable; |
| 24 | |
| 25 | typedef struct QError { |
| 26 | QObject_HEAD; |
| 27 | QDict *error; |
Markus Armbruster | 827b081 | 2010-02-18 19:46:49 +0100 | [diff] [blame] | 28 | Location loc; |
Luiz Capitulino | 9f9daf9 | 2009-11-18 23:05:30 -0200 | [diff] [blame] | 29 | int linenr; |
| 30 | const char *file; |
| 31 | const char *func; |
| 32 | const QErrorStringTable *entry; |
| 33 | } QError; |
| 34 | |
| 35 | QError *qerror_new(void); |
| 36 | QError *qerror_from_info(const char *file, int linenr, const char *func, |
| 37 | const char *fmt, va_list *va); |
Markus Armbruster | 77e595e | 2009-12-07 21:37:16 +0100 | [diff] [blame] | 38 | QString *qerror_human(const QError *qerror); |
Markus Armbruster | 827b081 | 2010-02-18 19:46:49 +0100 | [diff] [blame] | 39 | void qerror_print(QError *qerror); |
Luiz Capitulino | 9f9daf9 | 2009-11-18 23:05:30 -0200 | [diff] [blame] | 40 | QError *qobject_to_qerror(const QObject *obj); |
| 41 | |
| 42 | /* |
| 43 | * QError class list |
| 44 | */ |
Markus Armbruster | 56e9f56 | 2010-02-19 19:52:45 +0100 | [diff] [blame] | 45 | #define QERR_BAD_BUS_FOR_DEVICE \ |
| 46 | "{ 'class': 'BadBusForDevice', 'data': { 'device': %s, 'bad_bus_type': %s } }" |
| 47 | |
Markus Armbruster | 7bbd823 | 2010-02-19 18:05:39 +0100 | [diff] [blame] | 48 | #define QERR_BUS_NOT_FOUND \ |
| 49 | "{ 'class': 'BusNotFound', 'data': { 'bus': %s } }" |
| 50 | |
Markus Armbruster | 8eae73b | 2010-02-19 19:53:36 +0100 | [diff] [blame] | 51 | #define QERR_BUS_NO_HOTPLUG \ |
| 52 | "{ 'class': 'BusNoHotplug', 'data': { 'bus': %s } }" |
| 53 | |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 54 | #define QERR_COMMAND_NOT_FOUND \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 55 | "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }" |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 56 | |
Luiz Capitulino | 0df37c4 | 2009-12-07 21:36:59 +0100 | [diff] [blame] | 57 | #define QERR_DEVICE_ENCRYPTED \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 58 | "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s } }" |
Luiz Capitulino | 9f9daf9 | 2009-11-18 23:05:30 -0200 | [diff] [blame] | 59 | |
Markus Armbruster | 4d9a1a1 | 2010-02-19 19:53:54 +0100 | [diff] [blame^] | 60 | #define QERR_DEVICE_INIT_FAILED \ |
| 61 | "{ 'class': 'DeviceInitFailed', 'data': { 'device': %s } }" |
| 62 | |
Markus Armbruster | fc5469d | 2010-02-19 17:42:46 +0100 | [diff] [blame] | 63 | #define QERR_DEVICE_LOCKED \ |
Markus Armbruster | b086838 | 2009-12-07 21:37:03 +0100 | [diff] [blame] | 64 | "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }" |
| 65 | |
Markus Armbruster | 1ae7871 | 2010-02-19 18:05:59 +0100 | [diff] [blame] | 66 | #define QERR_DEVICE_MULTIPLE_BUSSES \ |
| 67 | "{ 'class': 'DeviceMultipleBusses', 'data': { 'device': %s } }" |
| 68 | |
Luiz Capitulino | 055f612 | 2009-11-18 23:05:34 -0200 | [diff] [blame] | 69 | #define QERR_DEVICE_NOT_ACTIVE \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 70 | "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }" |
| 71 | |
| 72 | #define QERR_DEVICE_NOT_FOUND \ |
| 73 | "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }" |
Luiz Capitulino | 055f612 | 2009-11-18 23:05:34 -0200 | [diff] [blame] | 74 | |
Markus Armbruster | 5cfe026 | 2009-12-07 21:37:04 +0100 | [diff] [blame] | 75 | #define QERR_DEVICE_NOT_REMOVABLE \ |
| 76 | "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }" |
| 77 | |
Markus Armbruster | 07574ba | 2010-02-19 18:06:18 +0100 | [diff] [blame] | 78 | #define QERR_DEVICE_NO_BUS \ |
| 79 | "{ 'class': 'DeviceNoBus', 'data': { 'device': %s } }" |
| 80 | |
Markus Armbruster | c7c338c | 2009-12-07 21:37:10 +0100 | [diff] [blame] | 81 | #define QERR_FD_NOT_FOUND \ |
Markus Armbruster | bd9d306 | 2009-12-08 13:33:54 +0100 | [diff] [blame] | 82 | "{ 'class': 'FdNotFound', 'data': { 'name': %s } }" |
Markus Armbruster | c7c338c | 2009-12-07 21:37:10 +0100 | [diff] [blame] | 83 | |
Markus Armbruster | 41471a2 | 2009-12-07 21:37:12 +0100 | [diff] [blame] | 84 | #define QERR_FD_NOT_SUPPLIED \ |
Markus Armbruster | bd9d306 | 2009-12-08 13:33:54 +0100 | [diff] [blame] | 85 | "{ 'class': 'FdNotSupplied', 'data': {} }" |
Markus Armbruster | 41471a2 | 2009-12-07 21:37:12 +0100 | [diff] [blame] | 86 | |
Markus Armbruster | 17901e7 | 2009-12-07 21:37:06 +0100 | [diff] [blame] | 87 | #define QERR_INVALID_BLOCK_FORMAT \ |
| 88 | "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }" |
| 89 | |
Markus Armbruster | 7a046f5 | 2009-12-07 21:37:13 +0100 | [diff] [blame] | 90 | #define QERR_INVALID_PARAMETER \ |
Markus Armbruster | bd9d306 | 2009-12-08 13:33:54 +0100 | [diff] [blame] | 91 | "{ 'class': 'InvalidParameter', 'data': { 'name': %s } }" |
Markus Armbruster | 7a046f5 | 2009-12-07 21:37:13 +0100 | [diff] [blame] | 92 | |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 93 | #define QERR_INVALID_PARAMETER_TYPE \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 94 | "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }" |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 95 | |
Luiz Capitulino | f6d855c | 2009-12-04 15:24:08 -0200 | [diff] [blame] | 96 | #define QERR_INVALID_PASSWORD \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 97 | "{ 'class': 'InvalidPassword', 'data': {} }" |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 98 | |
| 99 | #define QERR_JSON_PARSING \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 100 | "{ 'class': 'JSONParsing', 'data': {} }" |
| 101 | |
| 102 | #define QERR_KVM_MISSING_CAP \ |
| 103 | "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }" |
| 104 | |
| 105 | #define QERR_MISSING_PARAMETER \ |
| 106 | "{ 'class': 'MissingParameter', 'data': { 'name': %s } }" |
| 107 | |
Markus Armbruster | fc5469d | 2010-02-19 17:42:46 +0100 | [diff] [blame] | 108 | #define QERR_OPEN_FILE_FAILED \ |
| 109 | "{ 'class': 'OpenFileFailed', 'data': { 'filename': %s } }" |
| 110 | |
Markus Armbruster | c58a35f | 2010-02-19 13:11:41 +0100 | [diff] [blame] | 111 | #define QERR_PROPERTY_NOT_FOUND \ |
| 112 | "{ 'class': 'PropertyNotFound', 'data': { 'device': %s, 'property': %s } }" |
| 113 | |
Markus Armbruster | 06b4a70 | 2010-02-19 13:17:58 +0100 | [diff] [blame] | 114 | #define QERR_PROPERTY_VALUE_BAD \ |
| 115 | "{ 'class': 'PropertyValueBad', 'data': { 'device': %s, 'property': %s, 'value': %s } }" |
| 116 | |
Markus Armbruster | 9c5eff9 | 2010-03-16 17:40:48 +0100 | [diff] [blame] | 117 | #define QERR_PROPERTY_VALUE_IN_USE \ |
| 118 | "{ 'class': 'PropertyValueInUse', 'data': { 'device': %s, 'property': %s, 'value': %s } }" |
| 119 | |
Markus Armbruster | 84745d6 | 2010-03-16 17:44:38 +0100 | [diff] [blame] | 120 | #define QERR_PROPERTY_VALUE_NOT_FOUND \ |
| 121 | "{ 'class': 'PropertyValueNotFound', 'data': { 'device': %s, 'property': %s, 'value': %s } }" |
| 122 | |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 123 | #define QERR_QMP_BAD_INPUT_OBJECT \ |
| 124 | "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }" |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 125 | |
Markus Armbruster | 7a84cb2 | 2009-12-07 21:37:07 +0100 | [diff] [blame] | 126 | #define QERR_SET_PASSWD_FAILED \ |
| 127 | "{ 'class': 'SetPasswdFailed', 'data': {} }" |
| 128 | |
Markus Armbruster | a488be2 | 2009-12-07 21:37:14 +0100 | [diff] [blame] | 129 | #define QERR_TOO_MANY_FILES \ |
Markus Armbruster | bd9d306 | 2009-12-08 13:33:54 +0100 | [diff] [blame] | 130 | "{ 'class': 'TooManyFiles', 'data': {} }" |
Markus Armbruster | a488be2 | 2009-12-07 21:37:14 +0100 | [diff] [blame] | 131 | |
Markus Armbruster | fc5469d | 2010-02-19 17:42:46 +0100 | [diff] [blame] | 132 | #define QERR_UNDEFINED_ERROR \ |
| 133 | "{ 'class': 'UndefinedError', 'data': {} }" |
| 134 | |
Markus Armbruster | a6906e3 | 2009-12-07 21:37:08 +0100 | [diff] [blame] | 135 | #define QERR_VNC_SERVER_FAILED \ |
| 136 | "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }" |
| 137 | |
Luiz Capitulino | 9f9daf9 | 2009-11-18 23:05:30 -0200 | [diff] [blame] | 138 | #endif /* QERROR_H */ |