aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/mesonlib
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2022-03-13 01:01:55 +0200
committerGitHub <noreply@github.com>2022-03-13 01:01:55 +0200
commit69ade4f4cf0123b7c38476b2972290d3d2a76b93 (patch)
tree76cd64e75748b8af0b7c7c85f0b1b7a9b1f4c523 /mesonbuild/mesonlib
parentbfdbf7bf6545236fa1077e3eea03a4f599c4cb8e (diff)
parentff4c283b3ac29f9f0cf067ceac2b1348964baeee (diff)
downloadmeson-69ade4f4cf0123b7c38476b2972290d3d2a76b93.zip
meson-69ade4f4cf0123b7c38476b2972290d3d2a76b93.tar.gz
meson-69ade4f4cf0123b7c38476b2972290d3d2a76b93.tar.bz2
Merge pull request #9339 from dcbaker/submit/structured_sources
Structured Sources
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'''