1 # -*- coding: utf-8 -*-
5 # Copyright (c) 2017-2019 Red Hat Inc.
11 # This work is licensed under the terms of the GNU GPL, version 2.
12 # See the COPYING file in the top-level directory.
15 class QAPIError(Exception):
16 def __init__(self, info, col, msg):
17 Exception.__init__(self)
24 if self.col is not None:
25 assert self.info.line is not None
26 loc += ':%s' % self.col
27 return loc + ': ' + self.msg
30 class QAPIParseError(QAPIError):
31 def __init__(self, parser, msg):
33 for ch in parser.src[parser.line_pos:parser.pos]:
35 col = (col + 7) % 8 + 1
38 super().__init__(parser.info, col, msg)
41 class QAPISemError(QAPIError):
42 def __init__(self, info, msg):
43 super().__init__(info, None, msg)