]> Devi Nivas Git - chevron.git/commitdiff
Move SyntaxError handling into cli_main
authornoah morrison <noah@morrison.ph>
Thu, 9 Apr 2015 21:24:49 +0000 (17:24 -0400)
committernoah morrison <noah@morrison.ph>
Thu, 9 Apr 2015 21:24:49 +0000 (17:24 -0400)
Makes a little more sense there, as it's only meant to handle
exceptions if you're using the command line version.

chevron/main.py

index 8615ff01d0a3fa2d4be1c3cabfd559d9053a907d..1a7a5b4637a15404b448992fc7f329abe7924551 100755 (executable)
@@ -26,11 +26,7 @@ def main(template, data={}, **kwargs):
         }
 
         args.update(kwargs)
-        try:
-            return render(**args)
-        except SyntaxError as e:
-            print('Chevron: syntax error')
-            print('    ' + '\n    '.join(e.args[0].split('\n')))
+        return render(**args)
 
 
 def cli_main():
@@ -81,10 +77,12 @@ def cli_main():
 
     args = vars(parser.parse_args())
 
-    result = main(**args)
-    if result is None:
+    try:
+        print(main(**args))
+    except SyntaxError as e:
+        print('Chevron: syntax error')
+        print('    ' + '\n    '.join(e.args[0].split('\n')))
         exit(1)
-    print(result)
 
 if __name__ == '__main__':
     cli_main()