vOOlkan
An object oriented approach to Vulkan
VulkanException.h
Go to the documentation of this file.
1#ifndef VULKAN_EXCEPTION
2#define VULKAN_EXCEPTION
3
4#include <stdexcept>
5#include <string>
6#include <vulkan/vulkan.h>
7
8namespace Vulkan { class VulkanException; }
9
13class Vulkan::VulkanException : public std::runtime_error {
14 public:
15 VulkanException(const std::string& description, VkResult errorCode, const std::string& hint = "") :
16 std::runtime_error(description),
17 errorCode{ errorCode },
18 hint{ hint } {
19 }
20
21 VulkanException(const std::string& description, const std::string& hint) :
22 std::runtime_error(description),
23 errorCode{ VK_SUCCESS },
24 hint{ hint } {
25 }
26
27 VulkanException(const std::string& description) :
28 std::runtime_error(description),
29 errorCode{ VK_SUCCESS },
30 hint{ "" } {
31 }
32
33 const char* what() const noexcept override{
34 fullDescription = "\n? Vulkan runtime error";
35 if(errorCode != VK_SUCCESS) {
36 fullDescription += "\n\tcode: " + std::to_string(errorCode);
37 }
38 if (const std::string description = std::runtime_error::what(); description != "") {
39 fullDescription += "\n\tdescription: " + description;
40 }
41 if (hint != "") {
42 fullDescription += "\n\thint: " + hint;
43 }
44 return fullDescription.c_str();
45 }
46
47 private:
48 VkResult errorCode;
49 std::string hint;
50 mutable std::string fullDescription;
51};
52
53
54
55#endif
Generic runtime exception thrown by Vulkan-related functions.
Definition: VulkanException.h:13
VulkanException(const std::string &description)
Definition: VulkanException.h:27
VulkanException(const std::string &description, VkResult errorCode, const std::string &hint="")
Definition: VulkanException.h:15
VulkanException(const std::string &description, const std::string &hint)
Definition: VulkanException.h:21
const char * what() const noexcept override
Definition: VulkanException.h:33
Types of queue families.
Definition: Animations.h:17