summary refs log tree commit diff stats
path: root/scripts/qapi/error.py
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2019-10-23 13:39:08 +0100
committerPeter Maydell <peter.maydell@linaro.org>2019-10-23 13:39:08 +0100
commit69717d0f890e14cbdd668297751f9446d2e2a8fd (patch)
tree899680cc9b8e66c9cfc9fd09fd0a301f20415ba7 /scripts/qapi/error.py
parentec97eb6133e204c8c0ee492cfc9c7551b6297aca (diff)
parent5f76a7aac156ca75680dad5df4a385fd0b58f6b1 (diff)
downloadfocaccia-qemu-69717d0f890e14cbdd668297751f9446d2e2a8fd.tar.gz
focaccia-qemu-69717d0f890e14cbdd668297751f9446d2e2a8fd.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2019-10-22-v3' into staging
QAPI patches for 2019-10-22

# gpg: Signature made Tue 22 Oct 2019 15:56:36 BST
# gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
# gpg:                issuer "armbru@redhat.com"
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full]
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [full]
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2019-10-22-v3:
  qapi: Allow introspecting fix for savevm's cooperation with blockdev
  tests/qapi-schema: Cover feature documentation comments
  tests: qapi: Test 'features' of commands
  qapi: Add feature flags to commands
  tests/qapi-schema: Tidy up test output indentation
  qapi: Clear scripts/qapi/doc.py executable bits again
  qapi: Split up scripts/qapi/common.py
  qapi: Move gen_enum(), gen_enum_lookup() back to qapi/types.py
  qapi: Speed up frontend tests
  qapi: Eliminate accidental global frontend state
  qapi: Store pragma state in QAPISourceInfo, not global state
  qapi: Don't suppress doc generation without pragma doc-required

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'scripts/qapi/error.py')
-rw-r--r--scripts/qapi/error.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/qapi/error.py b/scripts/qapi/error.py
new file mode 100644
index 0000000000..b9f3751bea
--- /dev/null
+++ b/scripts/qapi/error.py
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+#
+# QAPI error classes
+#
+# Copyright (c) 2017-2019 Red Hat Inc.
+#
+# Authors:
+#  Markus Armbruster <armbru@redhat.com>
+#  Marc-André Lureau <marcandre.lureau@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.
+# See the COPYING file in the top-level directory.
+
+
+class QAPIError(Exception):
+    def __init__(self, info, col, msg):
+        Exception.__init__(self)
+        self.info = info
+        self.col = col
+        self.msg = msg
+
+    def __str__(self):
+        loc = str(self.info)
+        if self.col is not None:
+            assert self.info.line is not None
+            loc += ':%s' % self.col
+        return loc + ': ' + self.msg
+
+
+class QAPIParseError(QAPIError):
+    def __init__(self, parser, msg):
+        col = 1
+        for ch in parser.src[parser.line_pos:parser.pos]:
+            if ch == '\t':
+                col = (col + 7) % 8 + 1
+            else:
+                col += 1
+        QAPIError.__init__(self, parser.info, col, msg)
+
+
+class QAPISemError(QAPIError):
+    def __init__(self, info, msg):
+        QAPIError.__init__(self, info, None, msg)