1#!/usr/bin/env python 2# -*- coding: utf-8 -*- 3 4# 5# Copyright 2017, Data61 6# Commonwealth Scientific and Industrial Research Organisation (CSIRO) 7# ABN 41 687 119 230. 8# 9# This software may be distributed and modified according to the terms of 10# the BSD 2-Clause license. Note that NO WARRANTY is provided. 11# See "LICENSE_BSD2.txt" for details. 12# 13# @TAG(DATA61_BSD) 14# 15 16from __future__ import absolute_import, division, print_function, \ 17 unicode_literals 18from camkes.internal.seven import cmp, filter, map, zip 19 20from camkes.internal.exception import CAmkESError 21import six 22 23class ParseError(CAmkESError): 24 def __init__(self, content, location=None, filename=None, lineno=None): 25 assert isinstance(content, six.string_types) or isinstance(content, Exception) 26 if location is not None: 27 filename = location.filename 28 lineno = location.lineno 29 min_col = location.min_col 30 max_col = location.max_col 31 else: 32 min_col = None 33 max_col = None 34 msg = self._format_message(six.text_type(content), filename, lineno, 35 min_col, max_col) 36 super(ParseError, self).__init__(msg) 37 38class OutcallError(ParseError): 39 def __init__(self, content, location=None, filename=None, lineno=None): 40 # Allow other embedded syntaxes to have more full featured exceptions. 41 super(OutcallError, self).__init__(content, location, filename, lineno) 42 43class DtbBindingError(OutcallError): 44 def __init__(self, content): 45 # But I personally only care about transmitting a string. 46 super(DtbBindingError, self).__init__(content) 47 48class DtbBindingQueryFormatError(DtbBindingError): 49 def __init__(self, content): 50 super(DtbBindingQueryFormatError, self).__init__(content) 51 52class DtbBindingNodeLookupError(DtbBindingError): 53 def __init__(self, content): 54 super(DtbBindingNodeLookupError, self).__init__(content) 55 56class DtbBindingSyntaxError(DtbBindingError): 57 def __init__(self, content): 58 super(DtbBindingSyntaxError, self).__init__(content) 59 60class DtbBindingTypeError(TypeError, DtbBindingError): 61 def __init__(self, content): 62 super(DtbBindingTypeError, self).__init__(content) 63 64class DtbBindingNotImplementedError(NotImplementedError, DtbBindingError): 65 def __init__(self, content): 66 super(DtbBindingNotImplementedError, self).__init__(content) 67