aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/modules/fs.py4
-rw-r--r--test cases/common/220 fs module/meson.build4
2 files changed, 7 insertions, 1 deletions
diff --git a/mesonbuild/modules/fs.py b/mesonbuild/modules/fs.py
index 7d96995..53174d2 100644
--- a/mesonbuild/modules/fs.py
+++ b/mesonbuild/modules/fs.py
@@ -261,8 +261,10 @@ class FSModule(ExtensionModule):
try:
with open(path, encoding=encoding) as f:
data = f.read()
+ except FileNotFoundError:
+ raise MesonException(f'File {args[0]} does not exist.')
except UnicodeDecodeError:
- raise MesonException(f'decoding failed for {path}')
+ raise MesonException(f'decoding failed for {args[0]}')
# Reconfigure when this file changes as it can contain data used by any
# part of the build configuration (e.g. `project(..., version:
# fs.read_file('VERSION')` or `configure_file(...)`
diff --git a/test cases/common/220 fs module/meson.build b/test cases/common/220 fs module/meson.build
index a1e9c44..b860fc8 100644
--- a/test cases/common/220 fs module/meson.build
+++ b/test cases/common/220 fs module/meson.build
@@ -142,3 +142,7 @@ assert(fs.stem('foo/bar/baz.dll.a') == 'baz.dll', 'failed to get stem with compo
subdir('subdir')
subproject('subbie')
+
+testcase expect_error('File notfound does not exist.')
+ fs.read('notfound')
+endtestcase