File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -355,7 +355,7 @@ class Variant
355355 T get () const
356356 {
357357 if (mType != variant_trait_v<T>) {
358- throw runtime_error ( " Mismatch between types" );
358+ throw runtime_error_f ( " Variant::get: Mismatch between types %d %d. " , mType , variant_trait_v<T> );
359359 }
360360 return variant_helper<T>::get (&mStore );
361361 }
Original file line number Diff line number Diff line change @@ -338,3 +338,15 @@ TEST_CASE("VariantJSONConversionsTest")
338338 REQUIRE (vstrings[i] == vvstra.get <std::string*>()[i]);
339339 }
340340}
341+
342+ TEST_CASE (" VariantThrowing" )
343+ {
344+ Variant a (" true" );
345+ REQUIRE_THROWS_AS (a.get <int >(), o2::framework::RuntimeErrorRef);
346+ try {
347+ a.get <int >();
348+ } catch (RuntimeErrorRef& ref) {
349+ RuntimeError& error = error_from_ref (ref);
350+ REQUIRE (error.what == std::string (" Variant::get: Mismatch between types 4 0." ));
351+ }
352+ }
You can’t perform that action at this time.
0 commit comments