From 39a62206784915c69feec0d4e863b9347fd2893e Mon Sep 17 00:00:00 2001 From: Emma Broman Date: Tue, 17 Aug 2021 15:46:50 +0200 Subject: [PATCH] Provide useful error message on SpecificationError when creating a camera path --- src/navigation/path.cpp | 4 ++-- src/navigation/pathnavigator.cpp | 13 +++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/navigation/path.cpp b/src/navigation/path.cpp index 9ff3034c9e..c15a964b58 100644 --- a/src/navigation/path.cpp +++ b/src/navigation/path.cpp @@ -412,8 +412,8 @@ Path createPathFromDictionary(const ghoul::Dictionary& dictionary, Path::Type ty const std::optional duration = p.duration; bool hasStart = p.startState.has_value(); - const Waypoint startPoint = hasStart ? - Waypoint(NavigationState(p.startState.value())) : + const Waypoint startPoint = hasStart ? + Waypoint(NavigationState(p.startState.value())) : waypointFromCamera(); // TODO: also handle curve type here diff --git a/src/navigation/pathnavigator.cpp b/src/navigation/pathnavigator.cpp index 09ae0d7218..b284c5e840 100644 --- a/src/navigation/pathnavigator.cpp +++ b/src/navigation/pathnavigator.cpp @@ -47,7 +47,7 @@ namespace { "Default Path Type", "The defualt path type chosen when generating a path. See wiki for alternatives." " The shape of the generated path will be different depending on the path type." - // TODO (2021-08-15, emmbr) right now there is no way to specify a type for a + // TODO (2021-08-15, emmbr) right now there is no way to specify a type for a // single path instance, only for any created paths }; @@ -216,7 +216,7 @@ void PathNavigator::updateCamera(double deltaTime) { } void PathNavigator::createPath(const ghoul::Dictionary& dictionary) { - // @TODO (2021-08.16, emmbr): Improve how curve types are handled. + // @TODO (2021-08.16, emmbr): Improve how curve types are handled. // We want the user to be able to choose easily const int pathType = _defaultPathType; @@ -232,6 +232,15 @@ void PathNavigator::createPath(const ghoul::Dictionary& dictionary) { createPathFromDictionary(dictionary, Path::Type(pathType)) ); } + catch (const documentation::SpecificationError& e) { + LERROR("Could not create camera path"); + for (const documentation::TestResult::Offense& o : e.result.offenses) { + LERRORC(o.offender, ghoul::to_string(o.reason)); + } + for (const documentation::TestResult::Warning& w : e.result.warnings) { + LWARNINGC(w.offender, ghoul::to_string(w.reason)); + } + } catch (const ghoul::RuntimeError& e) { LERROR(fmt::format("Could not create path. Reason: ", e.message)); return;