From 22fa7fd57f9560b48c2f39d1747c3930934e5979 Mon Sep 17 00:00:00 2001 From: sam-astro <77079540+sam-astro@users.noreply.github.com> Date: Wed, 5 Jan 2022 09:24:21 -0500 Subject: [PATCH] Changed catch error type to boost::bad_any_cast --- Slang/anyops.h | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Slang/anyops.h b/Slang/anyops.h index f86cc6f..38851ed 100644 --- a/Slang/anyops.h +++ b/Slang/anyops.h @@ -11,25 +11,25 @@ bool AnyAsBool(any val) { return any_cast(val); } - catch (const std::exception&) + catch (boost::bad_any_cast &e) { try // Try converting to string { return any_cast(val) == "true"; } - catch (const std::exception&) + catch (boost::bad_any_cast &e) { try // Try converting to float { return any_cast(val) == 1.0f; } - catch (const std::exception&) // Try converting to int + catch (boost::bad_any_cast &e) // Try converting to int { try { return any_cast(val) == 1; } - catch (const std::exception&) // Does not convert, return + catch (boost::bad_any_cast &e) // Does not convert, return { return false; } @@ -46,19 +46,19 @@ string AnyAsString(any val) { return any_cast(val); } - catch (const std::exception&) + catch (boost::bad_any_cast &e) { try // Try converting to int { return to_string(any_cast(val)); } - catch (const std::exception&) + catch (boost::bad_any_cast &e) { try // Try converting to float { return to_string(any_cast(val)); } - catch (const std::exception&) // Try converting to bool + catch (boost::bad_any_cast &e) // Try converting to bool { try { @@ -66,7 +66,7 @@ string AnyAsString(any val) if (any_cast(val) == true) i = "true"; return i; } - catch (const std::exception&) // Does not convert, return + catch (boost::bad_any_cast &e) // Does not convert, return { return ""; } @@ -83,19 +83,19 @@ float AnyAsFloat(any val) { return any_cast(val); } - catch (const std::exception&) + catch (boost::bad_any_cast &e) { try // Try converting to int { return (float)any_cast(val); } - catch (const std::exception&) + catch (boost::bad_any_cast &e) { try // Try converting to string, then converting it to float { return stof(any_cast(val)); } - catch (const std::exception&) // Try converting to bool + catch (boost::bad_any_cast &e) // Try converting to bool { try { @@ -103,7 +103,7 @@ float AnyAsFloat(any val) if (any_cast(val) == true) i = 1; return i; } - catch (const std::exception&) // Does not convert, return + catch (boost::bad_any_cast &e) // Does not convert, return { return 0; } @@ -120,19 +120,19 @@ int AnyAsInt(any val) { return any_cast(val); } - catch (const std::exception&) + catch (boost::bad_any_cast &e) { try // Try converting to float { return (int)any_cast(val); } - catch (const std::exception&) + catch (boost::bad_any_cast &e) { try // Try converting to string, then converting it to int { return stoi(any_cast(val)); } - catch (const std::exception&) // Try converting to bool + catch (boost::bad_any_cast &e) // Try converting to bool { try { @@ -140,7 +140,7 @@ int AnyAsInt(any val) if (any_cast(val) == true) i = 1; return i; } - catch (const std::exception&) // Does not convert, return + catch (boost::bad_any_cast &e) // Does not convert, return { return 0; } @@ -159,28 +159,28 @@ int any_type(any val) int i = any_cast(val); return 0; } - catch (const std::exception&) + catch (boost::bad_any_cast &e) { try // Try converting to float { float f = any_cast(val); return 1; } - catch (const std::exception&) + catch (boost::bad_any_cast &e) { try // Try converting to bool { bool b = any_cast(val); return 2; } - catch (const std::exception&) // Try converting to string + catch (boost::bad_any_cast &e) // Try converting to string { try { string s = any_cast(val); return 3; } - catch (const std::exception&) // Does not convert, return + catch (boost::bad_any_cast &e) // Does not convert, return { return -1; } @@ -190,4 +190,4 @@ int any_type(any val) return -1; } -#endif \ No newline at end of file +#endif