From: Philippe Proulx Date: Wed, 12 Nov 2014 20:23:36 +0000 (-0500) Subject: Catch write errors X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=f8450909eda7a1f41d1cd2e8f78db0f5060607ea;p=deliverable%2Fbarectf.git Catch write errors --- 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. #