From f8450909eda7a1f41d1cd2e8f78db0f5060607ea Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Wed, 12 Nov 2014 15:23:36 -0500 Subject: [PATCH] Catch write errors --- barectf/cli.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/barectf/cli.py b/barectf/cli.py index b454160..04cb52d 100644 --- a/barectf/cli.py +++ b/barectf/cli.py @@ -1875,8 +1875,12 @@ class BarectfCodeGenerator: # name: file name # contents: file contents def _write_file(self, name, contents): - with open(os.path.join(self._output, name), 'w') as f: - f.write(contents) + path = os.path.join(self._output, name) + try: + with open(path, 'w') as f: + f.write(contents) + except Exception as e: + _perror('cannot write "{}": {}'.format(path, e)) # Converts a C block to actual C source lines. # -- 2.34.1