1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Copyright 2017, Data61
5# Commonwealth Scientific and Industrial Research Organisation (CSIRO)
6# ABN 41 687 119 230.
7#
8# This software may be distributed and modified according to the terms of
9# the BSD 2-Clause license. Note that NO WARRANTY is provided.
10# See "LICENSE_BSD2.txt" for details.
11#
12# @TAG(DATA61_BSD)
13#
14
15from __future__ import absolute_import, division, print_function, \
16    unicode_literals
17from camkes.internal.seven import cmp, filter, map, zip
18
19from camkes.internal.exception import CAmkESError
20
21class ASTError(CAmkESError):
22    '''
23    An error resulting from inconsistency detected in the AST.
24    '''
25    def __init__(self, message, entity):
26        self.entity = entity
27        if entity.location is not None:
28            msg = self._format_message(message, entity.location.filename,
29                entity.location.lineno, entity.location.min_col,
30                entity.location.max_col)
31        else:
32            msg = self._format_message(message)
33        super(ASTError, self).__init__(msg)
34