From d806df0a53f81b8c2f6ad801830965e5937f9afa Mon Sep 17 00:00:00 2001 From: Paul Gessinger Date: Tue, 3 Dec 2024 12:59:36 +0100 Subject: [PATCH] fix: Remove BoundCylinderToZPhi final, add exception (#3926) - I missed a `final` in one location (see #3923) - Adding an exception to `GridAccessJsonConverter::toJson`. This was previously silently returning an empty json object if none of the downcasts worked. Since the downcast chain is not exhaustive, I think it's better to throw if there's an unhandled case. --- Core/include/Acts/Utilities/GridAccessHelpers.hpp | 2 +- Plugins/Json/src/GridJsonConverter.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Core/include/Acts/Utilities/GridAccessHelpers.hpp b/Core/include/Acts/Utilities/GridAccessHelpers.hpp index fbaf7f3acbd..df8f46ed39b 100644 --- a/Core/include/Acts/Utilities/GridAccessHelpers.hpp +++ b/Core/include/Acts/Utilities/GridAccessHelpers.hpp @@ -212,7 +212,7 @@ class LocalSubspace : public IBoundToGridLocal { } }; -class BoundCylinderToZPhi final : public IBoundToGridLocal { +class BoundCylinderToZPhi : public IBoundToGridLocal { public: double radius = 1.; double shift = 0.; diff --git a/Plugins/Json/src/GridJsonConverter.cpp b/Plugins/Json/src/GridJsonConverter.cpp index 7b0bab73675..478224bc163 100644 --- a/Plugins/Json/src/GridJsonConverter.cpp +++ b/Plugins/Json/src/GridJsonConverter.cpp @@ -439,6 +439,11 @@ nlohmann::json Acts::GridAccessJsonConverter::toJson( jBoundToGridLocal["shift"] = boundCylinderToZPhi->shift; } + if (jBoundToGridLocal.empty()) { + throw std::invalid_argument( + "GridAccessJsonConverter: boundToGridLocal type not supported."); + } + return jBoundToGridLocal; }