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" |
| 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 | */ |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 41 | #define QERR_COMMAND_NOT_FOUND \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 42 | "{ 'class': 'CommandNotFound', 'data': { 'name': %s } }" |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 43 | |
Luiz Capitulino | 0df37c4 | 2009-12-07 21:36:59 +0100 | [diff] [blame] | 44 | #define QERR_DEVICE_ENCRYPTED \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 45 | "{ 'class': 'DeviceEncrypted', 'data': { 'device': %s } }" |
Luiz Capitulino | 9f9daf9 | 2009-11-18 23:05:30 -0200 | [diff] [blame] | 46 | |
Markus Armbruster | b086838 | 2009-12-07 21:37:03 +0100 | [diff] [blame] | 47 | #define QERR_DEVICE_LOCKED \ |
| 48 | "{ 'class': 'DeviceLocked', 'data': { 'device': %s } }" |
| 49 | |
Luiz Capitulino | 055f612 | 2009-11-18 23:05:34 -0200 | [diff] [blame] | 50 | #define QERR_DEVICE_NOT_ACTIVE \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 51 | "{ 'class': 'DeviceNotActive', 'data': { 'device': %s } }" |
| 52 | |
| 53 | #define QERR_DEVICE_NOT_FOUND \ |
| 54 | "{ 'class': 'DeviceNotFound', 'data': { 'device': %s } }" |
Luiz Capitulino | 055f612 | 2009-11-18 23:05:34 -0200 | [diff] [blame] | 55 | |
Markus Armbruster | 5cfe026 | 2009-12-07 21:37:04 +0100 | [diff] [blame] | 56 | #define QERR_DEVICE_NOT_REMOVABLE \ |
| 57 | "{ 'class': 'DeviceNotRemovable', 'data': { 'device': %s } }" |
| 58 | |
Markus Armbruster | 17901e7 | 2009-12-07 21:37:06 +0100 | [diff] [blame] | 59 | #define QERR_INVALID_BLOCK_FORMAT \ |
| 60 | "{ 'class': 'InvalidBlockFormat', 'data': { 'name': %s } }" |
| 61 | |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 62 | #define QERR_INVALID_PARAMETER_TYPE \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 63 | "{ 'class': 'InvalidParameterType', 'data': { 'name': %s,'expected': %s } }" |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 64 | |
Luiz Capitulino | f6d855c | 2009-12-04 15:24:08 -0200 | [diff] [blame] | 65 | #define QERR_INVALID_PASSWORD \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 66 | "{ 'class': 'InvalidPassword', 'data': {} }" |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 67 | |
| 68 | #define QERR_JSON_PARSING \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 69 | "{ 'class': 'JSONParsing', 'data': {} }" |
| 70 | |
| 71 | #define QERR_KVM_MISSING_CAP \ |
| 72 | "{ 'class': 'KVMMissingCap', 'data': { 'capability': %s, 'feature': %s } }" |
| 73 | |
| 74 | #define QERR_MISSING_PARAMETER \ |
| 75 | "{ 'class': 'MissingParameter', 'data': { 'name': %s } }" |
| 76 | |
| 77 | #define QERR_QMP_BAD_INPUT_OBJECT \ |
| 78 | "{ 'class': 'QMPBadInputObject', 'data': { 'expected': %s } }" |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 79 | |
Markus Armbruster | 7a84cb2 | 2009-12-07 21:37:07 +0100 | [diff] [blame] | 80 | #define QERR_SET_PASSWD_FAILED \ |
| 81 | "{ 'class': 'SetPasswdFailed', 'data': {} }" |
| 82 | |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 83 | #define QERR_UNDEFINED_ERROR \ |
Markus Armbruster | e16a181 | 2009-12-07 21:37:02 +0100 | [diff] [blame] | 84 | "{ 'class': 'UndefinedError', 'data': {} }" |
Luiz Capitulino | 4b9d468 | 2009-11-26 22:58:57 -0200 | [diff] [blame] | 85 | |
Markus Armbruster | a6906e3 | 2009-12-07 21:37:08 +0100 | [diff] [blame^] | 86 | #define QERR_VNC_SERVER_FAILED \ |
| 87 | "{ 'class': 'VNCServerFailed', 'data': { 'target': %s } }" |
| 88 | |
Luiz Capitulino | 9f9daf9 | 2009-11-18 23:05:30 -0200 | [diff] [blame] | 89 | #endif /* QERROR_H */ |