From 8ed6bb8a1b2c21819822da714b81a4f7b72bde58 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Fri, 14 Oct 2016 13:12:18 +0200 Subject: [PATCH] Asserts on valid v5 conforming maneuver types, resolves #3035 --- src/engine/api/json_factory.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/engine/api/json_factory.cpp b/src/engine/api/json_factory.cpp index 7e30e0004..f77c52a05 100644 --- a/src/engine/api/json_factory.cpp +++ b/src/engine/api/json_factory.cpp @@ -175,10 +175,18 @@ std::string modeToString(const extractor::TravelMode mode) util::json::Object makeStepManeuver(const guidance::StepManeuver &maneuver) { util::json::Object step_maneuver; + + std::string maneuver_type; + if (maneuver.waypoint_type == guidance::WaypointType::None) - step_maneuver.values["type"] = detail::instructionTypeToString(maneuver.instruction.type); + maneuver_type = detail::instructionTypeToString(maneuver.instruction.type); else - step_maneuver.values["type"] = detail::waypointTypeToString(maneuver.waypoint_type); + maneuver_type = detail::waypointTypeToString(maneuver.waypoint_type); + + // These invalid responses should never happen: log if they do happen + BOOST_ASSERT_MSG(maneuver_type != "invalid", "unexpected invalid maneuver type"); + + step_maneuver.values["type"] = std::move(maneuver_type); if (detail::isValidModifier(maneuver)) step_maneuver.values["modifier"] =