错误处理

This commit is contained in:
2026-08-16 18:33:24 +08:00
parent 8612b5ff86
commit 389ff81d42
44 changed files with 536 additions and 261 deletions
@@ -1,3 +1,4 @@
#include <renderive/error/Error_Policy.hpp>
#include "Renderable_Base_p.hpp"
#include <algorithm>
@@ -62,7 +63,7 @@ void Renderable_Base::Impl::bind_scene(
if (!current)
current = std::move(lifetime);
else if (current != lifetime)
throw std::invalid_argument("renderable belongs to another scene");
::renderive::error::unexpected<std::invalid_argument>("renderable belongs to another scene");
}
void Renderable_Base::Impl::rebuild_render_graph() {
@@ -90,7 +91,7 @@ Renderable_Base::Impl::render_graph_snapshot() {
[this, &next_identities](std::string_view key) {
const std::string logical_key(key);
if (next_identities.contains(logical_key))
throw std::invalid_argument(
::renderive::error::unexpected<std::invalid_argument>(
"duplicate render node logical key");
const auto current = node_identities.find(logical_key);
const Render_Node_Id node_id =
@@ -118,10 +119,10 @@ Renderable_Base::Impl::memory_resource() const noexcept {
Scene_Base& Renderable_Base::Impl::scene() const {
const auto lifetime = real_time_data_state->scene_lifetime;
if (!lifetime)
throw std::logic_error("renderable is not bound to a scene");
::renderive::error::unexpected<std::logic_error>("renderable is not bound to a scene");
auto lease = lifetime->acquire();
if (!lease)
throw std::logic_error("renderable scene is no longer alive");
::renderive::error::unexpected<std::logic_error>("renderable scene is no longer alive");
return lease.scene();
}
@@ -180,7 +181,7 @@ void Renderable_Base::Impl::capture_frame_data(Frame_Render_Snapshot&) const {}
void Renderable_Base::Impl::add_prepare_action(Prepare_Action action) {
if (!action)
throw std::invalid_argument("renderable prepare action is empty");
::renderive::error::unexpected<std::invalid_argument>("renderable prepare action is empty");
prepare_actions.push_back(std::move(action));
}
@@ -242,7 +243,7 @@ Renderable_Base::Renderable_Base(std::unique_ptr<Impl> implementation,
std::pmr::memory_resource& memory_resource)
: d_ptr(std::move(implementation)) {
if (!d_ptr)
throw std::invalid_argument("renderable implementation is null");
::renderive::error::unexpected<std::invalid_argument>("renderable implementation is null");
d_ptr->initialize(*this, configuration, memory_resource);
}