Catch write errors
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 12 Nov 2014 20:23:36 +0000 (15:23 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 12 Nov 2014 20:23:36 +0000 (15:23 -0500)
barectf/cli.py

index b4541603eb161b7605fe488dceeb1008b482e08e..04cb52dc0a7f575262712c00a47b59284ffa6513 100644 (file)
@@ -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.
     #
This page took 0.04954 seconds and 4 git commands to generate.