From 6740df4faf4f96083681c2a1bbdc010e2c5f3494 Mon Sep 17 00:00:00 2001 From: jeaye Date: Mon, 25 Jul 2016 11:40:22 -0700 Subject: [PATCH] Change readme example to catch std::exception (#4) There are two reasons for this change. 1) The C++ mantra "throw by value, catch by reference" still applies, even when you're only specifically throwing std::system_error at this time 2) Vulkan-Hpp is using C++ stdlib containers, such as std::string and std::vector, which have their own exception specifications to consider. The example provided may throw various exceptions, all of which derive from std::exception, and many will not be std::system_error. This is a serious issue in the readme simply because that snippet of code will be the copy/pasted foundation of many projects which adopt Vulkan-Hpp. We might as well try to avoid some common pitfalls of exception handling. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a07c35e..e638540 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ Here are a few code examples: device.allocateMemory(allocateInfo, nullptr); } - catch (std::system_error e) + catch (const std::exception &e) { std::cerr << "Vulkan failure: " << e.what() << std::endl; } @@ -223,4 +223,4 @@ NVIDIA is happy to review and consider pull requests for merging into the main t way deemed appropriate. Due to the required paperwork please refrain from providing pull requests for simple changes and file an issue describing a bug or the desired change instead. * Not all pull requests can be or will be accepted. NVIDIA will close pull requests that it does not intend to merge. -* The modified files and any new files must include the unmodified NVIDIA copyright header seen at the top of all shipping files. \ No newline at end of file +* The modified files and any new files must include the unmodified NVIDIA copyright header seen at the top of all shipping files.