diff --git a/libs/ecs/include/psemek/ecs/entity_container.hpp b/libs/ecs/include/psemek/ecs/entity_container.hpp index 04df8620..dc70f6c3 100644 --- a/libs/ecs/include/psemek/ecs/entity_container.hpp +++ b/libs/ecs/include/psemek/ecs/entity_container.hpp @@ -19,10 +19,10 @@ namespace psemek::ecs using query_cache = std::shared_ptr; - struct component_exception + struct component_not_found_exception : util::exception { - component_exception(std::type_info const & type, entity_handle const & handle, boost::stacktrace::stacktrace stacktrace = {}) + component_not_found_exception(std::type_info const & type, entity_handle const & handle, boost::stacktrace::stacktrace stacktrace = {}) : util::exception(util::to_string("Component ", util::type_name(type), " not found for entity ", handle), std::move(stacktrace)) , type_(type) , handle_(handle) @@ -60,7 +60,7 @@ namespace psemek::ecs /** Obtain a reference to the specified component type * of the accessed entity. * If the entity doesn't contain this component type, - * an exception of type `component_exception` is thrown. + * an exception of type `component_not_found_exception` is thrown. */ template Component & get(); @@ -323,8 +323,7 @@ namespace psemek::ecs { if (auto ptr = get_if()) return *ptr; - assert(false); - __builtin_unreachable(); + throw component_not_found_exception(typeid(Component), table_->get_entity_handles()[row_]); } template