lsfg-vk/lsfg-vk-common/include/common/exception.hpp
2025-07-12 18:27:12 +02:00

34 lines
1 KiB
C++

#pragma once
#include <vulkan/vulkan_core.h>
#include <stdexcept>
#include <string>
namespace LSFG {
/// Simple exception class for Vulkan errors.
class vulkan_error : public std::runtime_error {
public:
///
/// Construct a vulkan_error with a message and a Vulkan result code.
///
/// @param result The Vulkan result code associated with the error.
/// @param message The error message.
///
explicit vulkan_error(VkResult result, const std::string& message);
/// Get the Vulkan result code associated with this error.
[[nodiscard]] VkResult error() const { return this->result; }
// Trivially copyable, moveable and destructible
vulkan_error(const vulkan_error&) = default;
vulkan_error(vulkan_error&&) = default;
vulkan_error& operator=(const vulkan_error&) = default;
vulkan_error& operator=(vulkan_error&&) = default;
~vulkan_error() noexcept override;
private:
VkResult result;
};
}