From 3efb2c9b603476f6c7517236393f95c4a0862bc0 Mon Sep 17 00:00:00 2001 From: Riccardo Maria Bianchi <riccardo.maria.bianchi@cern.ch> Date: Thu, 13 Jun 2024 02:41:07 +0200 Subject: [PATCH] throw exception if wrong variant data --- .../GeoModelHelpers/GeoModelHelpers/variantHelpers.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/GeoModelCore/GeoModelHelpers/GeoModelHelpers/variantHelpers.h b/GeoModelCore/GeoModelHelpers/GeoModelHelpers/variantHelpers.h index 6c298fb15..a68a3a933 100644 --- a/GeoModelCore/GeoModelHelpers/GeoModelHelpers/variantHelpers.h +++ b/GeoModelCore/GeoModelHelpers/GeoModelHelpers/variantHelpers.h @@ -12,6 +12,8 @@ #ifndef GEOMODELHELPERS_VARIANTHELPERS_H #define GEOMODELHELPERS_VARIANTHELPERS_H +#include "GeoModelHelpers/throwExcept.h" + #include <iostream> #include <string> #include <vector> @@ -55,7 +57,7 @@ namespace GeoModelHelpers { } catch (std::bad_variant_access const &ex) { - std::cout << ex.what() << ": '" << logMsg << "' is not a 'string'! " << getFromVariant_Type(record) << "\n"; + THROW_EXCEPTION(std::string(ex.what()) + ": '" + std::string(logMsg) + "' is not a '" + std::string(type) + "'! It's a '" + getFromVariant_Type(record) + "'."); } return ret; } @@ -70,7 +72,8 @@ namespace GeoModelHelpers { } catch (std::bad_variant_access const &ex) { - std::cout << ex.what() << ": '" << logMsg << "' is not a '" << type << "'! " << getFromVariant_Type(record) << "\n"; + THROW_EXCEPTION(std::string(ex.what()) + ": '" + std::string(logMsg) + "' is not a '" + std::string(type) + "'! It's a '" + getFromVariant_Type(record) + "'."); + } return ret; } @@ -84,7 +87,7 @@ namespace GeoModelHelpers { } catch (std::bad_variant_access const &ex) { - std::cout << ex.what() << ": '" << logMsg << "' is not a '" << type << "'! " << getFromVariant_Type(record) << "\n"; + THROW_EXCEPTION(std::string(ex.what()) + ": '" + std::string(logMsg) + "' is not a '" + std::string(type) + "'! It's a '" + getFromVariant_Type(record) + "'."); } return ret; } @@ -113,7 +116,6 @@ namespace GeoModelHelpers { } else { type = "UNKOWN"; } - std::cout << "Variant is of type '" << type << "'" << std::endl; return type; } }; -- GitLab