From 61229569bfcb6f053eb4b1bbf803881c6c9c0ed6 Mon Sep 17 00:00:00 2001 From: Johannes Schanda Date: Wed, 18 Sep 2013 14:40:10 +0200 Subject: Make exceptions optional & fix incorrectly documented throw --- src/CommonAPI/Runtime.h | 3 --- src/CommonAPI/SerializableVariant.hpp | 5 +++++ src/test/VariantTest.cpp | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/CommonAPI/Runtime.h b/src/CommonAPI/Runtime.h index 0a93ccc..15fc05c 100644 --- a/src/CommonAPI/Runtime.h +++ b/src/CommonAPI/Runtime.h @@ -87,9 +87,6 @@ class Runtime { * @param middlewareIdOrAlias A well known name or an alias for a binding * * @return The runtime object for specified binding, or null if any error occurred. - * - * @throw std::invalid_argument if a path for this middlewareId has been configured, but no appropriate library - * could be found there. */ static std::shared_ptr load(const std::string& middlewareIdOrAlias); diff --git a/src/CommonAPI/SerializableVariant.hpp b/src/CommonAPI/SerializableVariant.hpp index 2919638..febff2d 100644 --- a/src/CommonAPI/SerializableVariant.hpp +++ b/src/CommonAPI/SerializableVariant.hpp @@ -453,8 +453,13 @@ const _Type & Variant<_Types...>::get() const { if (cType == valueType_) { return *(reinterpret_cast(&valueStorage_)); } else { +#ifdef __EXCEPTIONS std::bad_cast toThrow; throw toThrow; +#else + printf("SerializableVariant.hpp:%i %s: Incorrect access to variant; attempting to get type not currently contained", __LINE__, __FUNCTION__); + abort(); +#endif } } diff --git a/src/test/VariantTest.cpp b/src/test/VariantTest.cpp index 8854951..ed793f5 100755 --- a/src/test/VariantTest.cpp +++ b/src/test/VariantTest.cpp @@ -103,8 +103,9 @@ TEST_F(VariantTest, VariantTestPack) { const int& myIntCopy2 = myVariantCopy2.get(); EXPECT_EQ(myIntCopy2, fromInt); - +#ifdef __EXCEPTIONS EXPECT_ANY_THROW(const int& myFake = myVariant.get()); +#endif EXPECT_TRUE(myVariant.isType()); -- cgit v1.2.1