diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2018-07-06 23:47:15 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2018-07-07 04:33:24 -0700 |
commit | 2093d45a4e1203d868d200628918472877c7ec31 (patch) | |
tree | a7253981585f71f5bd3a0053deff8ed90ad690ee /mesonbuild/mesonlib.py | |
parent | 80392225a61a5baa28ef1f45bfc19b4623d2d188 (diff) | |
download | meson-2093d45a4e1203d868d200628918472877c7ec31.zip meson-2093d45a4e1203d868d200628918472877c7ec31.tar.gz meson-2093d45a4e1203d868d200628918472877c7ec31.tar.bz2 |
Print a more usable message when a subproject fails to configure
Instead of just printing the message in the exception, if it's
a MesonException, also print the file and the line number. If it's an
unknown exception, print the entire traceback so that we can pin-point
what the Meson bug causing it is.
Diffstat (limited to 'mesonbuild/mesonlib.py')
-rw-r--r-- | mesonbuild/mesonlib.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index f3682ce..efb8d11 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -83,6 +83,13 @@ an_unpicklable_object = threading.Lock() class MesonException(Exception): '''Exceptions thrown by Meson''' + def get_msg_with_context(self): + s = '' + if hasattr(self, 'lineno') and hasattr(self, 'file'): + s = get_error_location_string(self.file, self.lineno) + ' ' + s += str(self) + return s + class EnvironmentException(MesonException): '''Exceptions thrown while processing and creating the build environment''' @@ -1047,6 +1054,9 @@ def detect_subprojects(spdir_name, current_dir='', result=None): result[basename] = [trial] return result +def get_error_location_string(fname, lineno): + return '{}:{}:'.format(fname, lineno) + class OrderedSet(collections.MutableSet): """A set that preserves the order in which items are added, by first insertion. |