From a208b849f337a60f87216575bc148d8de20517b6 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 29 Oct 2021 12:23:45 -0500 Subject: [PATCH] vulkan: Rework mako error handling in python generators Suggested-by: Dylan Baker Reviewed-by: Dylan Baker Part-of: --- src/vulkan/util/vk_cmd_queue_gen.py | 10 ++++------ src/vulkan/util/vk_commands_gen.py | 10 ++++------ src/vulkan/util/vk_dispatch_table_gen.py | 10 ++++------ src/vulkan/util/vk_entrypoints_gen.py | 10 ++++------ src/vulkan/util/vk_physical_device_features.py | 10 ++++------ 5 files changed, 20 insertions(+), 30 deletions(-) diff --git a/src/vulkan/util/vk_cmd_queue_gen.py b/src/vulkan/util/vk_cmd_queue_gen.py index 539392a..3c0d7e6 100644 --- a/src/vulkan/util/vk_cmd_queue_gen.py +++ b/src/vulkan/util/vk_cmd_queue_gen.py @@ -435,12 +435,10 @@ def main(): # to print a useful stack trace and prints it, then exits with # status 1, if python is run with debug; otherwise it just raises # the exception - if __debug__: - import sys - from mako import exceptions - sys.stderr.write(exceptions.text_error_template().render() + '\n') - sys.exit(1) - raise + import sys + from mako import exceptions + print(exceptions.text_error_template().render(), file=sys.stderr) + sys.exit(1) if __name__ == '__main__': main() diff --git a/src/vulkan/util/vk_commands_gen.py b/src/vulkan/util/vk_commands_gen.py index 610c835..004e18c 100644 --- a/src/vulkan/util/vk_commands_gen.py +++ b/src/vulkan/util/vk_commands_gen.py @@ -132,12 +132,10 @@ def main(): # to print a useful stack trace and prints it, then exits with # status 1, if python is run with debug; otherwise it just raises # the exception - if __debug__: - import sys - from mako import exceptions - sys.stderr.write(exceptions.text_error_template().render() + '\n') - sys.exit(1) - raise + import sys + from mako import exceptions + print(exceptions.text_error_template().render(), file=sys.stderr) + sys.exit(1) if __name__ == '__main__': main() diff --git a/src/vulkan/util/vk_dispatch_table_gen.py b/src/vulkan/util/vk_dispatch_table_gen.py index eb6b0cd..abfa63b 100644 --- a/src/vulkan/util/vk_dispatch_table_gen.py +++ b/src/vulkan/util/vk_dispatch_table_gen.py @@ -963,12 +963,10 @@ def main(): # to print a useful stack trace and prints it, then exits with # status 1, if python is run with debug; otherwise it just raises # the exception - if __debug__: - import sys - from mako import exceptions - sys.stderr.write(exceptions.text_error_template().render() + '\n') - sys.exit(1) - raise + import sys + from mako import exceptions + print(exceptions.text_error_template().render(), file=sys.stderr) + sys.exit(1) if __name__ == '__main__': diff --git a/src/vulkan/util/vk_entrypoints_gen.py b/src/vulkan/util/vk_entrypoints_gen.py index 078b6da..4c911d6 100644 --- a/src/vulkan/util/vk_entrypoints_gen.py +++ b/src/vulkan/util/vk_entrypoints_gen.py @@ -248,12 +248,10 @@ def main(): # to print a useful stack trace and prints it, then exits with # status 1, if python is run with debug; otherwise it just raises # the exception - if __debug__: - import sys - from mako import exceptions - sys.stderr.write(exceptions.text_error_template().render() + '\n') - sys.exit(1) - raise + import sys + from mako import exceptions + print(exceptions.text_error_template().render(), file=sys.stderr) + sys.exit(1) if __name__ == '__main__': main() diff --git a/src/vulkan/util/vk_physical_device_features.py b/src/vulkan/util/vk_physical_device_features.py index b9665e5..57282ac 100644 --- a/src/vulkan/util/vk_physical_device_features.py +++ b/src/vulkan/util/vk_physical_device_features.py @@ -239,12 +239,10 @@ def main(): # to print a useful stack trace and prints it, then exits with # status 1, if python is run with debug; otherwise it just raises # the exception - if __debug__: - import sys - from mako import exceptions - sys.stderr.write(exceptions.text_error_template().render() + '\n') - sys.exit(1) - raise + import sys + from mako import exceptions + print(exceptions.text_error_template().render(), file=sys.stderr) + sys.exit(1) if __name__ == '__main__': main() -- 2.7.4