aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib
diff options
context:
space:
mode:
Diffstat (limited to 'mesonbuild/mesonlib')
-rw-r--r--mesonbuild/mesonlib/universal.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py
index c7cb561..d4f51c1 100644
--- a/mesonbuild/mesonlib/universal.py
+++ b/mesonbuild/mesonlib/universal.py
@@ -41,6 +41,7 @@ if T.TYPE_CHECKING:
from ..build import ConfigurationData
from ..coredata import KeyedOptionDictType, UserOption
from ..compilers.compilers import Compiler
+ from ..mparser import BaseNode
FileOrString = T.Union['File', str]
@@ -171,6 +172,15 @@ class MesonException(Exception):
self.lineno = lineno
self.colno = colno
+ @classmethod
+ def from_node(cls, *args: object, node: BaseNode) -> MesonException:
+ """Create a MesonException with location data from a BaseNode
+
+ :param node: A BaseNode to set location data from
+ :return: A Meson Exception instance
+ """
+ return cls(*args, file=node.filename, lineno=node.lineno, colno=node.colno)
+
class MesonBugException(MesonException):
'''Exceptions thrown when there is a clear Meson bug that should be reported'''