From 3ab8959669be3bd7232a8aa1859eb651fcdf05b3 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 1 May 2021 18:39:05 +0100 Subject: Error on bad cast of named type --- lib/persistence.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/persistence.h') diff --git a/lib/persistence.h b/lib/persistence.h index 5ef1400..86b0dce 100644 --- a/lib/persistence.h +++ b/lib/persistence.h @@ -196,14 +196,17 @@ namespace Persistence { auto no = Persistable::callSharedFactory(type); if (auto tno = std::dynamic_pointer_cast(no)) { this->v = std::move(tno); + return; } } else { auto no = Persistable::callFactory(type); if (dynamic_cast(no.get())) { this->v.reset(static_cast(no.release())); + return; } } + throw std::runtime_error("Named type doesn't cast to target type"); } }; -- cgit v1.2.3