@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
#
-# QAPI error classes
-#
# Copyright (c) 2017-2019 Red Hat Inc.
#
# Authors:
@@ -11,6 +9,14 @@
# This work is licensed under the terms of the GNU GPL, version 2.
# See the COPYING file in the top-level directory.
+"""
+QAPI error classes
+
+Common error classes used throughout the package. Additional errors may
+be defined in other modules. At present, `QAPIParseError` is defined in
+parser.py.
+"""
+
class QAPIError(Exception):
"""Base class for all exceptions from the QAPI package."""
@@ -33,17 +39,5 @@ def __str__(self):
return loc + ': ' + self.msg
-class QAPIParseError(QAPISourceError):
- """Error class for all QAPI schema parsing errors."""
- 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
- super().__init__(parser.info, msg, col)
-
-
class QAPISemError(QAPISourceError):
"""Error class for semantic QAPI errors."""
@@ -18,10 +18,22 @@
import os
import re
-from .error import QAPIParseError, QAPISemError
+from .error import QAPISemError, QAPISourceError
from .source import QAPISourceInfo
+class QAPIParseError(QAPISourceError):
+ """Error class for all QAPI schema parsing errors."""
+ 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
+ super().__init__(parser.info, msg, col)
+
+
class QAPISchemaParser:
def __init__(self, fname, previously_included=None, incl_info=None):