Make ecs::entity_accessor::get throw the documented exception
This commit is contained in:
parent
6bab38a545
commit
d3fa7fdfea
1 changed files with 4 additions and 5 deletions
|
|
@ -19,10 +19,10 @@ namespace psemek::ecs
|
||||||
|
|
||||||
using query_cache = std::shared_ptr<detail::query_cache>;
|
using query_cache = std::shared_ptr<detail::query_cache>;
|
||||||
|
|
||||||
struct component_exception
|
struct component_not_found_exception
|
||||||
: util::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))
|
: util::exception(util::to_string("Component ", util::type_name(type), " not found for entity ", handle), std::move(stacktrace))
|
||||||
, type_(type)
|
, type_(type)
|
||||||
, handle_(handle)
|
, handle_(handle)
|
||||||
|
|
@ -60,7 +60,7 @@ namespace psemek::ecs
|
||||||
/** Obtain a reference to the specified component type
|
/** Obtain a reference to the specified component type
|
||||||
* of the accessed entity.
|
* of the accessed entity.
|
||||||
* If the entity doesn't contain this component type,
|
* 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 <typename Component>
|
template <typename Component>
|
||||||
Component & get();
|
Component & get();
|
||||||
|
|
@ -323,8 +323,7 @@ namespace psemek::ecs
|
||||||
{
|
{
|
||||||
if (auto ptr = get_if<Component>())
|
if (auto ptr = get_if<Component>())
|
||||||
return *ptr;
|
return *ptr;
|
||||||
assert(false);
|
throw component_not_found_exception(typeid(Component), table_->get_entity_handles()[row_]);
|
||||||
__builtin_unreachable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Component>
|
template <typename Component>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue