From 4ccc652a0656a09b5baf8b0723dd256ca8293a4d Mon Sep 17 00:00:00 2001 From: Robert Morell Date: Wed, 1 Feb 2017 14:51:00 -0800 Subject: cube: Error handling improvements - Add a newline to the end of the error message when printing to stdout for ERR_EXIT. - Handle demo_read_spv failures by calling ERR_EXIT rather than just continuing on and calling the Vulkan library with a NULL pointer. --- demos/cube.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'demos/cube.cpp') diff --git a/demos/cube.cpp b/demos/cube.cpp index e5fa6ae2..096bf0b0 100644 --- a/demos/cube.cpp +++ b/demos/cube.cpp @@ -64,7 +64,7 @@ #else #define ERR_EXIT(err_msg, err_class) \ do { \ - printf(err_msg); \ + printf("%s\n", err_msg); \ fflush(stdout); \ exit(1); \ } while (0) @@ -1555,6 +1555,9 @@ struct Demo { vk::ShaderModule prepare_fs() { size_t size = 0; void *fragShaderCode = read_spv("cube-frag.spv", &size); + if (!fragShaderCode) { + ERR_EXIT("Failed to load cube-frag.spv", "Load Shader Failure"); + } frag_shader_module = prepare_shader_module(fragShaderCode, size); @@ -1861,6 +1864,9 @@ struct Demo { vk::ShaderModule prepare_vs() { size_t size = 0; void *vertShaderCode = read_spv("cube-vert.spv", &size); + if (!vertShaderCode) { + ERR_EXIT("Failed to load cube-vert.spv", "Load Shader Failure"); + } vert_shader_module = prepare_shader_module(vertShaderCode, size); -- cgit v1.2.3